#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ll t,n,i,j;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int arr[n];
		for(i=0;i<n;i++)
		{
			cin>>arr[i];
		}
		sort(arr,arr+n);
		if(arr[n-1]==arr[0])
		{
			cout<<0<<"\n";
			continue;
		}
		for(i=1;i<n;i++)
		{
			if(arr[i]>arr[0])
			{
				cout<<n-i<<"\n";
				break;
			}
		}
	}	
}

