#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define in read()
#define fur(i,a,b) for(int i=a;i<=b;i++)
#define fdr(i,a,b) for(int i=a;i>=b;i--)
#define xx 100001
inline int read()
{
	int x=0,f=1;char ch=getchar();
	for(;!isalnum(ch);ch=getchar()) if(ch=='-') f=-1;
	for(;isalnum(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
int ss[xx],s[xx],a[xx],q[xx];
int n;
inline int check(int k)
{
	memset(ss,0,sizeof(ss));
	int mid=q[k];
	fur(i,1,n)
	{
		s[i]=(a[i]<mid)?(-1):1;
		ss[i]=ss[i-1]+s[i];
	}
	int sum=0;
	for(int i=0;i<n;i+=2)
	{
		int j=i>>2;
		sum=sum+(n-i)*(ss[n-j]-ss[j]);
	}
	if(sum>0) return 1;
	if(sum<0) return 0;
	if(sum==0) return 2;
}
int main()
{
	n=in;
	fur(i,1,n) a[i]=q[i]=in;
	sort(q+1,q+n+1);
	int head=1,tail=n;
	while(head<tail)
	{
		int mid=head+tail>>1;
		int ff=check(mid);
		if(ff==1) head=mid+1;
		if(ff==0) tail=mid-1;
		if(ff==2)
		{
			printf("%d\n",mid);
			return 0;
		}
	}
	printf("%d\n",q[head]);
	return 0;
}