#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int ma = 1e5 + 5;
const double pi = 3.14;
#define endl '\n'
using namespace std;
int a[100005];
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        ll n;
        int mi = inf;
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
            mi = min(mi, a[i]);
        }
        int cnt = 0;
        for (int i = 1; i <= n; i++)
        {
            if (mi == a[i])
            {
                cnt++;
            }
        }
        cout << n - cnt << endl;
    }
    return 0;
}