#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long N,a1[100005],a2[100005],F[200005],pre[100005],l,r,mid;
void insert(long long n)
{
	for(;n<=N*2+1;n+=n&-n)
	F[n]+=1;
}
int find(long long n)
{
	int cnt=0;
	for(;n;n-=n&-n)
	cnt+=F[n];
	return cnt;
}
bool check(long long n)
{
	memset(F,0,sizeof(F));
	memset(pre,0,sizeof(pre));
	long long cnt=0;
	long long zj=a2[n];
	if(a1[1]<=zj) pre[1]=-1;
	else pre[1]=1;
	for(int i=2;i<=N;i++)
	if(a1[i]<=zj) pre[i]=pre[i-1]-1;
	else pre[i]=pre[i-1]+1;
	for(int i=1;i<=N;i++)
	{
		cnt+=i-find(pre[i]+N+1)-1;
		insert(pre[i]+N+1);
	}
	if(cnt<=N*(N+1)/2/2)
	return true;
	return false;
}
int main()
{
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
	{
		scanf("%lld",&a1[i]);
		a2[i]=a1[i];
	}
	sort(a2+1,a2+N+1);
	l=1,r=N;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		l=mid;
		else
		r=mid;
	}
	printf("%lld",a2[r]);
	return 0;
}