#include <bits/stdc++.h>
using namespace std;
#define fst ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define vi vector<int>
#define vll vector<long long>
#define lb lower_bound
#define ub upper_bound
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define coutArray(a,n) for(int i = 0; i < n; i++){cout << a[i] << " ";};cout << endl;
#define sp std::setprecision(9)
typedef long long ll;
#define mod 1000000007
int fact(int n); 
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
int main()
{
    fst;
    int t=1;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int min=INT_MAX;
        int count=0;
        for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            if(x<min)
            {
                min=x;
                count=0;
            }
            if(x==min)
            {
                count++;
            }
           
        }
        cout<<n-count<<endl;;
    }
}



