#include<bits/stdc++.h>
using namespace std;

#define long_inf LLONG_MAX
#define long_neg_inf LLONG_MIN
#define inf INT_MAX
#define neg_inf INT_MIN
#define M 1e9+7
#define pb push_back

typedef long long int ll;


void solve(){
    int n;cin >> n;
    if(n==1){
    	cout << 0 << endl;
    	return;
    }
    vector<int>a;
    for(int i=0;i<n;i++){
    	int temp; cin >> temp;
    	a.pb(temp);
    }

    sort(a.begin(),a.end());
    int first = a[0];
    int ans=0;
    for(int x : a){
    	if(x==first){
    		ans++;
    	}
    	else{
    		break;
    	}
    }
    cout << a.size()-ans << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int t;
    cin >> t;
    while(t--)
        solve();
    return 0;
}