#include <bits/stdc++.h>
using namespace std;
 
void solveOne()
{
    int n;
    cin >> n;
    vector<int> heroes(n);
    for (int i = 0; i < n; i++)
        cin >> heroes[i];
 
    int mn = *min_element(heroes.begin(), heroes.end());
    auto mnCount = count(heroes.begin(), heroes.end(), mn);
 
    cout << n - mnCount << '\n';
}
 
void setupIo()
{
    std::ios::sync_with_stdio(false);
 
    #ifndef ONLINE_JUDGE 
  
    // For getting input from input.txt file 
    freopen("input.txt", "r", stdin); 
  
    // Printing the Output to output.txt file 
    freopen("output.txt", "w", stdout); 
  
    #endif 
}
 
int main()
{
    setupIo();
 
    int tc;
    cin >> tc;
    while(tc--)
        solveOne();
}