#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll mod = 1e9+7;


void solve(){
  int a;
  cin>>a;
  float arr[a];
  float sum=0;
    for(int i=0;i<a;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
float avg = sum/(float)a;
sort(arr,arr+a);
int ans=0;
 for(int i=0;i<a;i++){
       if(arr[i]>arr[0])
       ans++;
    }
cout<<ans<<endl;

}


int main(){
 int t;
 cin>>t;
 while(t--){
   solve();
 }
}