#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct BinaryIndexedTree {
    vector<int> data;
    int n;
    BinaryIndexedTree(int n) : data(n+1), n(n+1) {}

    void update(int i,long x){
        for(; i <= n; i += i & -i) data[i] += x;
    }

    long query(int i){
        long ret = 0;
        for(; i > 0; i -= i & -i) ret += data[i];
        return ret;
    }
};

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    long n; cin >> n;
    long a[100010]; for(int i = 0; i < n; ++i) cin >> a[i];

    int l = 0, r = 2e9;
    while(r - l > 1) {
        long mid = (l + r) / 2;
        BinaryIndexedTree bit(n * 2);
        long sum = n + 1, num = 0;
        bit.update(sum, 1);

        for(int i = 0; i < n; ++i) {
            sum += (a[i] <= mid ? 1 : -1);
            num += bit.query(sum - 1);
            bit.update(sum, 1);
        }

        if(num > n * (n + 1) / 2 - num) r = mid;
        else l = mid;
    }

    cout << r << endl;
    return 0;
}