#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) x.begin(), x.end()

void solve()
{
    ll n, total = 0;
    cin >> n;
    vector<double> arr(n);
    for (ll i = 0; i <= n - 1; i++)
    {
        cin >> arr[i];
        total += arr[i];
    }
    sort(all(arr));
    ll c = 0;
    for (ll i = 1; i <= n - 1; i++)
    {
        if (arr[i] > arr[0])
            c++;
    }
    cout << c << "\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}