#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 1005
using namespace std;
int n;
int s[N][N];
struct node
{
	int sum, cnt;
}a[N];
bool cmp(node x, node y)
{
	return x.sum > y.sum;
};
long long al;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i].sum);
	for(int i = 1; i <= n; ++i)
	for(int j = 1; j <= n; ++j)
		if(a[j].sum < a[i].sum) s[i][j] = s[i][j - 1] + 1;
		else s[i][j] = s[i][j - 1];
	for(int i = 1; i <= n; ++i)
	{
		for(int j = i; j <= n; ++j)
		for(int k = i; k <= j; ++k)
		if(s[k][j] - s[k][i - 1] == (j - i + 1) / 2)
		{
			++a[k].cnt; break;
			}
	}
	sort(a + 1, a + n + 1, cmp);
	al = (long long) n * (n - 1) / 2 + n;
	al = (al + 1) / 2;
	for(int i = 1; i <= n; ++i)
	{
		al -= a[i].cnt;
		if(al <= 0)
		{
			printf("%d", a[i].sum); break;
		}
	}
	return 0;
}