#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define pb push_back
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define PI 3.14159265358979323846264338327950288419716939937510
#define ll long long
#define ld long double
#define vi vector <int>
#define vb vector<bool>
#define vvi vector <vector<int>>
#define vvb vector <vector<bool>>
#define vvvi vector <vector<vector<int>>>
#define vll vector<ll>
#define vvl vector <vector<ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define FIO   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs(x) fixed<<setprecision(x)
#define print(a) {for(auto x:a){cout << x << " ";}}
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// template <typename T>
// using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;

void run_case() {
	int n;
	cin >> n;
	vi a(n);
	int cnt = 0, mn = 1e9;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mn = min(mn, a[i]);
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == mn)cnt++;
	}
	cout << n - cnt << endl;
}
auto clk = clock();
int main()
{

	FIO
#ifndef ONLINE_JUDGE

	//for getting input from input.txt
	freopen("input.txt", "r", stdin);
	//for writting output to output.txt
	freopen("output.txt", "w", stdout);
	// for writing error
	freopen("error.txt", "w", stderr);
#endif
	int t;
	cin >> t;
	//t = 1;
	while (t--) {
		run_case();
	}
#ifndef ONLINE_JUDGE
	cout << endl
	     << "Time elapsed: " << fs(10) << (double)(clock() - clk) / CLOCKS_PER_SEC << endl
	     << endl;
#endif
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * in case of segmentation fault check for ex- a variable declared more than once , or index becoming negative
    * check TLE due to not clearing adjacency list for each test
    * do smth instead of nothing and stay organized
    * BELIEVE in yourself
*/