#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>

using namespace std;

typedef long long ll;

int main() {
	ll tt;
	cin >> tt;
	for (int i = 0; i < tt; i++) {
		ll n;
		cin >> n;
		vector<ll> v(n);
		for (int i = 0; i < n; i++) {
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		ll cnt = 0;
		for (int i = 1; i < n; i++) {
			if (v[i] != v[0]) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
 }