#include "bits/stdc++.h"
using namespace std;

static long long N = 200000, M, L = -1, R = 1000000001, A[100010] = {}, BIT[200010] = {};
vector<long long> V;

void Add(int X, long long Y) {
	for (int i = X; i <= N + 1; i += i & -i) BIT[i] += Y;
}

long long Sum(int X) {
	long long Ret = 0;
	for (int i = X; i > 0; i -= i & -i) Ret += BIT[i];
	return Ret;
}

int main() {
	cin >> M;
	for (int i = 0; i < M; i++) cin >> A[i];
	while (R - L > 1) {
		long long MID = (L + R) / 2, COUNT = 0;
		static long long X[100010] = {};
		X[0] = 100001;
		for (int i = 0; i < M; i++) {
			if (A[i] < MID) X[i + 1] = X[i] - 1;
			else X[i + 1] = X[i] + 1;
		}
		for (int i = 0; i <= 200000; i++) BIT[i] = 0;
		for (int i = 0; i <= M; i++) {
			COUNT += Sum(X[i]);
			Add(X[i], 1);
		}
		if (COUNT < M * (M + 1) / 2 - COUNT) R = MID;
		else L = MID;
 	}
	cout << L << endl;
}