#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAXN 1<<17
using namespace std;
int n, len, l, r; long long cnt,tot;
int a[MAXN], sum[MAXN], t[MAXN], T[MAXN];
void merge_sort(int nl, int nr){
    if (nl == nr) return;
    int mid = (nl + nr) >> 1;
    int p = nl, q = mid+1, now = nl;
    merge_sort(nl, mid);
    merge_sort(mid+1, nr);
    while (p <= mid && q <= nr){
        if (sum[p] < sum[q]){
            T[now++] = sum[p++];
        }
        else {
            tot += (p-nl);
            T[now++] = sum[q++];
        }
    }
    while (p <= mid) T[now++] = sum[p++];
    while (q <= nr) {
        tot += (p-nl);
        T[now++] = sum[q++];
    }
    for (int i = nl;i <= nr;++i){
        sum[i] = T[i];
    }
}
bool check(int ans){
    sum[0] = 0;
    for (int i = 1;i <= n;++i){
        if (a[i] <= ans) sum[i] = sum[i-1]+1;
        else sum[i] = sum[i-1]-1;
    }
    tot = 0;
    merge_sort(0, n);
    return tot >= (cnt/2+1) ;
}
void solve(){
    int mid;
    while (l < r){
        mid = (l+r) >> 1;
        if (check(mid)) r = mid;
        else l = mid+1;
    }
    printf("%d\n", r);
}
void input(){
    scanf("%d", &n);
    l = 1e9+10;
    r = 0;
    for (int i = 1;i <= n;++i){
        scanf("%d", &a[i]);
        r = max(r ,a[i]);
        l = min(l, a[i]);
        cnt += i;
    }
    solve();
}
int main(){
    input();
    return 0;
}