#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
const int N = 2e5 + 10, NN = 1e6;
const int mod = 7 + 1e9;
const ll oo = 1e9;
double eps = 1e-9;
void Ifyoufailtryagain(){
int n;
cin >> n;
int mx = 0;
map<int, int> fr;
for(int i=0, t; i<n; ++i){
cin >> t;
fr[t]++;
mx = max(mx, t);
}
cout << (fr[mx] == 1 ? n : (fr[mx] == 2 ? n-1 : -1)) << '\n';
return;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int t = 1;
cin >> t;
while (t--)
Ifyoufailtryagain();
}
Copy