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

int main()
{
    ll t; cin>>t;
    while(t--)
    {
        ll n; cin>>n;
        ll a[n];
        for(ll i=0; i<n; i++)
        {
            cin>>a[i];
        }
        sort(a, a+n);
        int temp=n-1;
        ll ans=1;
        
        while(temp>0)
        {
            if(a[temp]==a[0]) ans=ans+1;
            temp--;
        }
        cout<<(n-ans)<<endl;
    }
}