#include <bits/stdc++.h> 
#include <iterator>
#include <utility>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))
#define SWAP(type, a, b) { const type tmp = a; a = b; b = tmp; }
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,l,r) for(ll i=(l);i>=(r);i--)
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define inf 1e9
#define llinf 2e18
#define mod (ll)1e9 + 7
#define tc ll t; cin>>t; while(t--)
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 

void solve(){
    int n;
    cin >> n;
    vi list(n);
    int min = inf;
    rep(i,0,n)
    {
        cin >> list[i];
        if(min>list[i])
        {
            min = list[i];
        }
    }
    int final = 0;
    rep(i,0,n)
    {
        if(list[i]==min)
        {
            final++;
        }
    }
    cout << n-final << endl;
    return;
}
 
int main()
{
       godspeed;
//     #ifndef ONLINE_JUDGE
//         freopen("input.txt", "r", stdin);
//         freopen("output.txt", "r", stdout);
//     #endif
    tc{
        solve();
    }
    return 0;
}