#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<functional>
using namespace std;
 
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
typedef long long ll;
const int MAXN = 1e3+5, INF = 0x3f3f3f3f, MOD = 998244353;
const ll INFL = 0x3f3f3f3f3f3f3f3f;

int a[MAXN];
void run(){
    int n; cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    int mn = *min_element(a+1,a+1+n);
    int ans=0;
    for(int i=1;i<=n;i++)if(a[i] > mn)ans++;
    cout<<ans<<'\n';
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int t=1;
    cin>>t;
    while(t--)run();
    return 0;
}