#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))

using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        int mini=INT_MAX;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mini=min(mini,a[i]);
        }
        int cnt=0;
        for(int i=0;i<n;i++){
            if(a[i]==mini){
                cnt++;
            }
        }
        cout<<(n-cnt)<<endl;
    }
    return 0;
}