#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;

int32_t main()
{
    int t=1;
	cin >> t;
	while (t--)
    {
        int n,mini=LONG_LONG_MAX,ans=0;
        cin >> n;
        int a[n];
        for(int i=0;i<n;i++)
            cin >> a[i],mini=min(mini,a[i]);
        for(int i=0;i<n;i++)
            if(a[i]!=mini)
                ans++;
        cout << ans << endl;

    }
    return 0;
}
