#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
const int N=505;
int n,a[N];
int main()
{
	int T; scanf("%d",&T);
	while (T--)
	{
		scanf("%d",&n);
		int minn=0x3f3f3f3f,ans=0;
		for (int i=1;i<=n;i++)
		{
			scanf("%d",a+i);
			if (a[i]<minn){ans=0; minn=a[i];}
			if (a[i]==minn) ++ans;
		} printf("%d\n",n-ans);
	} return 0;
}