#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int main() {
	int t;
	cin >> t;
	int n;
	vector <int> heroes;
	int tmp;
	int possibleWinners = 0;
	int currentMin = 200;
	vector <int> result;
	for (int i = 0; i < t; ++i) {
		cin >> n;
		for (int j = 0; j < n; ++j) {
			cin >> tmp;
			if (tmp < currentMin) currentMin = tmp;
			result.push_back(tmp);
		}
		for (auto& e : result) {
			if (e > currentMin) possibleWinners++;
		}
		cout << possibleWinners << endl;
		possibleWinners = 0;
		result.clear();
		currentMin = 200;
	}
 	return 0;
}