fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val sorted = A.sorted()
    var left = 0
    var right = N
    val x = 1L * N * (N + 1) / 4
    while (left + 1 < right) {
        val mid = (left + right) / 2
        val am = sorted[mid]
        val s = IntArray(N + 1)
        for (n in 0 until N) {
            s[n + 1] = s[n] + if (A[n] >= am) 1 else -1
        }
        val bit = BIT(2 * N + 1)
        var sum = 0L
        for (n in 0 until N + 1) {
            sum += bit.sum(s[n] + N)
            bit.add(s[n] + N, 1)
        }
        if (x <= sum) {
            left = mid
        } else {
            right = mid
        }
    }
    println(sorted[left])
}

class BIT(size: Int) {
    private val bit: LongArray
    init { bit = LongArray(size) }
    fun sum(n: Int): Long {
        var k = n
        var s = 0L
        while (k > 0) {
            s += bit[k]
            k -= k and -k
        }
        return s
    }
    fun add(n: Int, x: Long) {
        var k = n
        while (k < bit.size) {
            bit[k] += x
            k += k and -k
        }
    }
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
