aboutsummaryrefslogtreecommitdiff
path: root/contests/21-04-2022(Div.4)/B
blob: d1b3e986f6c7d8ed8b66f4b60eea01994b9502e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>

using namespace std;

auto solve(map<int, int> m){
  for(auto x : m){
    if(x.second >= 3){
      return x.first;
    }
  }
  return -1;
}

int main(){
  int tt, x, n;
  cin >> tt;
  while(tt--){
    map<int, int> frq;
    vector<int> v;
    cin >> n;
    for(int i = 0; i < n; i++){
      cin >> x;
      frq[x]++;
    }
    // for(auto &x : frq){
    //   v.push_back(x.second);
    // }
    cout << solve(frq) << endl;
  }
}