#include<bits/stdc++.h>
#include<fstream>
#define cy cout<<"YES"<<endl
#define cn cout<<"NO"<<endl
#define ll long long int
#define pb push_back
#define mod 1000003
#define thakkar ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll nCr1[1001][1001];
ll nCr(ll n,ll r)
{
    if(nCr1[n][r])return nCr1[n][r]; 
    if(r==1) return nCr1[n][r]=n;
    if(n==r) return nCr1[n][r]=1;
    if(r==0) return nCr1[n][r]=1;
    return nCr1[n][r]=(nCr(n-1,r) + nCr(n-1,r-1))%mod;
}
bool prime(ll n)
{
    ll i;
    for(i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}
ll mul(ll n)
{
    ll r,s=1;
    while(n>0)
    {
        r=n%10;
        s=s*r;
        n=n/10;
    }
    return s;
}
int main()
{
    thakkar
    ll t,n,i;
    cin>>t;
    while(t>0)
    {
        cin>>n;
        ll a[n];
        for(i=0;i<n;i++)
        cin>>a[i];
        sort(a,a+n);
        for(i=0;i<n;i++)
        {
            if(a[i]==a[0])
            continue;
            else
            break;
        }
        cout<<n-i<<endl;
        t--;
    }
}