#include <fstream>
#include <iostream>
#include <ctime>
#include <cstdlib>
#define nmax 1000005
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int n, k;
int A[nmax];
void read() {
fin >> n;
for (int i = 1; i <= n; i++)
fin >> A[i];
k = (n>>1);
}
int q(int st, int dr) {
int i = st;
int j = dr;
int pivot = A[i+rand()%(j-i+1)];
while (1) {
for (; A[i] < pivot;) i++;
for (; A[j] > pivot;) j--;
if (i <= j)
swap(A[i++], A[j--]);
else
return j;
}
return 0;
}
void solve(int st, int dr, int k) {
if (st == dr)
return;
int hi = q(st, dr);
int len = hi - st + 1;
if (k <= len)
solve(st, hi, k);
else
solve(hi+1, dr, k-len);
}
int main() {
srand(time(NULL));
read();
solve(1, n, k);
int nr = 0;
for (int i = 1; i <= n; i++)
if (A[i] == A[k])
nr++;
nr > (n>>1) ? fout << A[k] : fout << -1;
fin.close();
fout.close();
return 0;
}