#include <iostream>
#include <vector>
#include <fstream>
#include <set>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
const int INF = 1e9;


int main()
{
	int t;
	cin >> t;
	for (int g = 0; g < t; g++){
		int n;
		cin >> n;
		int a[n];
		int mn = INF;
		for (int i = 0; i < n; i++){
			cin >> a[i];
			mn = min(mn, a[i]);
		}
		int rez = 0;
		for (int i = 0; i < n; i++){
			if (a[i] != mn) rez++;
		}
		cout << rez << "\n";
	}
	
	return 0;
}