#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll n;
		cin>>n;
		ll a[n];
		for(int i=0;i<n;i++)
			cin>>a[i];
		ll m = *(min_element(a,a+n));
		ll count=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]==m)
				count++;
		}
		cout<<n-count<<"\n";
	}
}