#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define rep(i,s,e) for (int i = s; i < e; ++i)
#define rev(i,s,e) for (int i = s; i > e; --i)

const int N = 2e5 + 99 ;



int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef CLion
    freopen("input.txt" , "r" , stdin);
//    freopen("output.txt", "w" , stdout);
#endif

    int t; cin >> t;
    while ( t-- ){
        int n ; cin >> n;
        vector<int> vec(n);
        for ( int &i : vec ){
            cin >> i;
        }
        sort( all(vec) );
        cout << n - (upper_bound(all(vec) , vec.front()) - vec.begin()) << "\n";
    }
    return 0;
}