#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll n,a[maxn],tree[maxn*2],pre[maxn*2],l,r;
void add(int x,ll v){
	for(int i=x;i<=2*maxn;i+=i&-i)
    	tree[i]+=v;
}
ll ask(int x){
    ll ans=0;
    for(int i=x;i>0;i-=i&-i)
    	ans+=tree[i];
    return ans;
}
bool check(int mid){
	memset(tree,0,sizeof(tree));
	pre[0]=0;
	ll ans=0;
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+(a[i]>=mid?1:-1);
	for(int i=0;i<=n;++i){
		ans+=ask(pre[i]+maxn); 
		add(pre[i]+maxn,1);
	}
	return ans>=n*(n+1)/4;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
	 	cin>>a[i];
	 	r=max(r,a[i]);
    }
    while(l<=r){
    	int mid=(l+r)>>1; 
    	if(check(mid))l=mid+1;
		else r=mid-1; 
    }
    cout<<r;
	return 0;
} 
