#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;

    while(t--){
        int n,val;
        cin>>n;
        vector<int> a;
        for(int i=0;i<n;i++){
            cin>>val;
            a.push_back(val);
        }

        int m = *min_element(a.begin(),a.end());
        int b = count(a.begin(),a.end(),m);
      
        cout<<a.size()-b<<"\n"; 
    }
    return 0;
}