#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
int i,j,count1 = 0,count2 = 0;
for(i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
for(i=0;i<n;i++){
if(a[i]>a[n/2]) count1++;
else if(a[i]<a[n/2])count2++;
}
if(count1 == count2) printf("%d",a[n/2]);
else printf("-1");
return 0;
}
时间: 2024-10-29 19:08:40