#include <iostream>
#include "algorithm"
#include "cmath"
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt;
cin >> tt;
while (tt--) {
int size;
cin >> size;
long long arr[size];
for (int i = 0; i < size; i++) {
cin >> arr[i];
}
int max = arr[0];
for (int j = 1; j < size; j++) {
if (max < arr[j])
max = arr[j];
}
int counter = 0;
for (int k = 0; k < size; k++) {
if (arr[k] == max) {
counter++;
}
else
continue;
}
if (counter == 2)
cout << size - 1 << endl;
else if (counter == 1)
cout << size << endl;
else
cout << -1 << endl;
}
}
Copy