#include <bits/stdc++.h>
using namespace  std;
#define ll long long
ll t,n;

int main() {
    cin >> t;
    while(t--){
        cin >> n ;
        int A[n];
        for(int i=0;i<n;++i) cin >> A[i];
        int m=*min_element(A,A+n);
        int cnt=count(A,A+n,m);
        cout << n-cnt<< '\n';

    }
}