#include<iostream>
#include<cstdio>
#define mid ((l+r)>>1)
#define read(n) scanf("%d",&n)
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
int a[MAXN] ,  binary[MAXN];
int pre[MAXN];
int b[MAXN];
ll ans;
int n;
void merge(int *p,int l,int r)
{
	if(l == r)	return ;
	merge(p,l,mid);
	merge(p,mid+1,r);
	int tot = l;
	int pos1 = l , pos2 = mid + 1;
	while(pos1 <= mid && pos2 <= r)
	{
		if(p[pos1] > p[pos2])
		{
			b[tot++] = p[pos2++];
			ans += mid - pos1 + 1;
		}	
		else
			b[tot++] = p[pos1++];
	}
	while(pos1 <= mid)	b[tot++] = p[pos1++];
	while(pos2 <= r)	b[tot++] = p[pos2++];
	for(int i = l ; i <= r ; i++)
		p[i] = b[i];
}
bool check(int x)
{
	ans = 0;
	pre[0] = 0;
	for(int i = 1 ; i <= n ; i++)
		pre[i] = pre[i-1] + (x >= a[i] ? -1 : 1);
	merge(pre,1,n);
	return ans <= (long long)(n * (n + 1) / 4);
}
int main()
{
	read(n);
	for(int i = 1 ; i <= n ; i++)
		read(a[i]) , binary[i] = a[i];
	merge(binary,1,n);
	ans = 0;
	int l = 1 , r = n;
	while(l + 1 < r)
	{
		if(check(binary[mid]))
			l = mid;
		else
			r = mid;
	}
	printf("%d\n",binary[r]); 
}