#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define v vector<ll>
#define pb push_back
#define endl "\n"
#define mod1 1000000007
#define mod2 998244353
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
ll powe(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)
			res=(res*a)%mod1;
		b/=2;
		a=(a*a)%mod1;
	}
	return res;
}
void solve()
{
	ll n,i,x;
	cin>>n;
	v vec(n+1,0);
	for(i=1;i<=n;i++)
		cin>>vec[i];
	sort(vec.begin()+1,vec.end());
	x=vec[1];
	if(n==1)
		cout<<0<<endl;
	else
	{
		x=vec[1];
		for(i=2;i<=n;i++)
		{
			if(x!=vec[i])
				break;
		}
		if(i>n)
			cout<<0<<endl;
		else
			cout<<n-i+1<<endl;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r",stdin);
	freopen("output.txt", "w",stdout);
#endif
	int t;
	cin>>t;
	while(t--)
		solve();
}