#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int tc;
    cin>>tc;
    while(tc--){
        int n;  cin>>n;
        vector<int>p(n);
        for(int i=0; i<n; i++){
          cin>>p[i];
        }

        int min_level = *min_element(p.begin(),p.end());
        int count = 0;
        for(int i=0; i<n; i++){
                if(p[i] > min_level){
                    count++;
                }
            }
        cout<<count<<endl;
        }
}
