//C++版本
#include<iostream>
using namespace std;
#define N 1000
int a[N];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
int bigger_num = 0, smaller_num = 0;
for (int j = 0; j < n; j++) {
if (a[i] > a[j]) smaller_num++;
else if(a[i] < a[j]) bigger_num++;
}
if (bigger_num == smaller_num) {
cout << a[i] << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}
