#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
void MOUST(){
ios_base::sync_with_stdio(0);
cin.tie(0);
}
int main(){
MOUST();
int q;cin>>q;
while(q--){
ll n;cin>>n;
ll a[n],k=0,p=-1;
for(int i=0;i<n;i++){
cin>>a[i];
p=max(p,a[i]);
}
//cout<<k<<" ";
sort(a,a+n);
for(int i=n-1;i>=0;i--){
if(a[i]==p)
k++;
else
break;
}
if(n-k+1==1)
cout<<-1<<"\n";
else
cout<<n-k+1<<"\n";
}
}