两个网站都通过
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1010;
int n;
int a[N];
int main()
{
cin >> n;
for(int i = 0; i < n; ++ i) cin >> a[i];
nth_element(a, a + n / 2, a + n);
int cnt1 = 0, cnt2 = 0;
for(int i = 0; i < n; ++ i)
if(a[i] > a[n / 2]) cnt1 ++;
else if(a[i] < a[n / 2]) cnt2 ++;
if(cnt1 == cnt2) cout << a[n / 2] << endl;
else cout << -1 << endl;
return 0;
}