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

int func()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)    cin>>a[i];
    int count = 1;
    int min1 = a[0];
    for(int i = 1;i<n;i++)
    {
        if(min1>a[i])
        {
            min1 = a[i];
            count = 1;
        }
        else if(min1==a[i])
            count++;
    }

    return n-count;

}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
       cout<<func()<<"\n";
    }


}
