#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t, n;
    cin>>t;

    while(t--)
    {
        cin>>n;
        int arr[n];

        int least = INT_MAX, temp;
        for(int i = 0; i < n; i++)
        {
            cin>>temp;
            arr[i] = temp;

            least = min(least, temp);
        }
        int ans =0;

        for(int i = 0; i < n; i++)
        {
            if(arr[i] == least)
            {
                ans++;
            }
        }

        ans = (n-ans);

        cout<<ans<<endl;
    }
}