#include <bits/stdc++.h>
using namespace std;
int n,a[100005],sum[100005],temp[100005];
long long cnt,num;
void merge_sort(int l,int r)
{
	if(l>=r) return;
	int mid=(l+r)/2;
	merge_sort(l,mid);
	merge_sort(mid+1,r);
	int i=l,j=mid+1,k=l;
	while(i<=mid&&j<=r)
	{
		if(sum[i]<=sum[j]) temp[k++]=sum[i++];
		else cnt+=mid-i+1,temp[k++]=sum[j++];
	}
	while(i<=mid) temp[k++]=sum[i++];
	while(j<=r) temp[k++]=sum[j++];
	for(i=l;i<=r;i++) sum[i]=temp[i];
}
bool check(int x)
{
	sum[0]=cnt=0;
	for(int i=1;i<=n;i++) sum[i]=a[i]<=x?-1:1;
	for(int i=1;i<=n;i++) sum[i]+=sum[i-1];
	merge_sort(0,n);
	return cnt>=num/2+1;
}
int main()
{
	int l=INT_MAX,r=INT_MIN;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),l=min(l,a[i]),r=max(r,a[i]),num+=i;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<r<<endl;
	return 0;
}