#include<bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;

int main(){
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<int> zoz(n); for (auto& i : zoz){cin >> i;}
        int mini = zoz[0];
        int count = 1;
        for (int i = 1; i<n; i++){
            if (zoz[i] == mini){
                count++;
            }else if (zoz[i]<mini){
                mini = zoz[i];
                count = 1;
            }
        }
        cout << n-count << "\n";
    }
}