#include"bits/stdc++.h"

using namespace std;

#define Fast_D               cout<<fixed<<setprecision(13);
#define FastIO               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int                  long long
#define double               long double
#define all(v)               v.begin(),v.end()
#define scanstr(s)           cin>>ws; getline(cin,s);

#define Local = 1;
#ifdef Local
#define debug(x)             cout << __LINE__ << " " << #x <<"..." << x << endl;
#else
#define debug(x);
#define dev(x);
#define des(x);
#endif

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	int a[n];
	int l = 1e18;
	map<int,int> m;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		l = min(a[i],l);
		m[a[i]]++;
	}
	cout << n - m[l] << "\n";
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	cin >> T ;
	while(T--) solve();
}

