#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pc pop_back
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int a[n],count=0,mini=INT_MAX;
        for(int i=0;i<n;i++)
        {
            cin >> a[i];
            mini=min(a[i],mini);
        }
        for(int i=0;i<n;i++)
        {
            if(a[i]==mini)
                count++;
        }
        cout << n-count;
        cout << endl;
    }
    return 0;
}