// Problem: A. Eshag Loves Big Arrays
// Contest: Codeforces - Codeforces Round #722 (Div. 2)
// URL: https://codeforces.com/contest/1529/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MSV(X, V) memset((X), V, sizeof((X)))
#define LEN(X) strlen(X + 1)
#define SIZ(X) ((int)X.size())
#define MP make_pair
#define PB push_back
#define EB emplace_back

/* SORT_AND_UNIQUE */

template <class T>
void REV(T *a, int n) {
    reverse(a + 1, a + 1 + n);
}

template <class T>
void SRT(T *a, int n) {
    sort(a + 1, a + 1 + n);
}

template <class T>
int UNI(T *a, int n) {
    sort(a + 1, a + 1 + n);
    return unique(a + 1, a + 1 + n) - (a + 1);
}

template <class T>
int POS(T *a, int n, T v) {
    return lower_bound(a + 1, a + 1 + n, v) - a;
}

/* READ_AND_WRITE */

template <class T>
void _R(T &x) {
    cin >> x;
}
void _R(int &x) {
    scanf("%d", &x);
}
void _R(ll &x) {
    scanf("%lld", &x);
}
void _R(double &x) {
    scanf("%lf", &x);
}
void _R(char &x) {
    scanf(" %c", &x);
}
void _R(char *x) {
    scanf("%s", x + 1);
}
void R() {
}
template <class T, class... U>
void R(T &head, U &...tail) {
    _R(head);
    R(tail...);
}
template <class T>
void RN(T *a, int n) {
    for(int i = 1; i <= n; ++i)
        _R(a[i]);
}

template <class T>
void _W(const T &x) {
    cout << x;
}
void _W(const int &x) {
    printf("%d", x);
}
void _W(const ll &x) {
    printf("%lld", x);
}
void _W(const double &x) {
    printf("%.12f", x);
}
void _W(const char &x) {
    putchar(x);
}
void _W(const char *x) {
    printf("%s", x + 1);
}
template <class T, class U>
void _W(const pair<T, U> &x) {
    _W(x.F);
    putchar(' ');
    _W(x.S);
}
template <class T>
void _W(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _W(*i++))
        if(i != x.cbegin())
            putchar(' ');
}
void W() {
}
template <class T, class... U>
void W(const T &head, const U &...tail) {
    _W(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    W(tail...);
}
template <class T>
void WN(T *a, int n) {
    for(int i = 1; i <= n; ++i) {
        _W(a[i]);
        putchar(" \n"[i == n]);
    }
}

#ifdef LOCAL
#define D(x) cerr << #x << " = " << x << endl
#else
#define D(x)
#endif

/* CMIN_AND_CMAX */

template <typename T>
void cmin(T &x, T y) {
    if(y < x)
        x = y;
}

template <typename T>
void cmax(T &x, T y) {
    if(y > x)
        x = y;
}

const int INF = 0x3F3F3F3F;
const ll LINF = 0x3F3F3F3F3F3F3F3FLL;

/*****************/
/* MY_CODE_BEGIN */

const int MAXN = 2e5 + 5;

int n;
int a[MAXN];

void purin_solve() {
    R(n);
    RN(a, n);
    sort(a + 1, a + 1 + n);
    printf("%d\n", n - count(a + 1, a + 1 + n, a[1]));
}

int main() {
#ifdef LOCAL
    freopen("A.in", "r", stdin);
#endif // LOCAL
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
    int t = 1;
    R(t);
    while(t--)
        purin_solve();
    return 0;
}
