#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 101000;
int n, nums[N], vec[N], sum[N], t[N];
long long merge( int l, int r ){
	if( l == r )
		return 0;
	int mid = (l+r) / 2;
	long long res = merge(l, mid) + merge(mid+1, r);
	int i = l, j = mid+1, k = l;
	while( i <= mid || j <= r ){
		if( j > r || (i <= mid && sum[i] <= sum[j]) )
			t[k++] = sum[i++];
		else
			t[k++] = sum[j++], res += mid - i + 1;
	}
	for( int i = l; i <= r; ++i )
		sum[i] = t[i];
	return res;
}
bool check( int x ){
	for( int i = 1; i <= n; ++i )
		sum[i] = sum[i-1] + (nums[i] < x ? -1 : 1);
	return merge(0, n) * 2 <= (long long)n * (n+1) / 2;
}
int main(){
	scanf("%d", &n);
	for( int i = 1; i <= n; ++i ){
		scanf("%d", &nums[i]);
		vec[i] = nums[i];
	}
	sort(vec+1, vec+1+n);
	int m = unique(vec+1, vec+1+n)-vec;
	int l = 0, r = m-1;
	while( l < r ){
		int mid = (l+r+1) / 2;
		if( check(vec[mid]) )
			l = mid;
		else
			r = mid-1;
	}
	printf("%d\n", vec[r]);
	return 0;
}