解法:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> arr(n);
vector<int> tong(1000);
for (auto& x : arr) {
cin >> x;
tong[x]++;
}
int p=max_element(tong.begin(), tong.end()) - tong.begin();
if (tong[p] > n / 2) {
cout << p;
}
else cout << -1;
return 0;
}