#include <iostream>
#include <iomanip>
#include<iterator> // for iterators
#include<vector> // for vectors
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <unordered_map>
using namespace std;

int main()
{
    int t, n, temp; scanf("%d", &t);
    vector<int> v;
    while (t --)
    {
        scanf("%d", &n);
        for (int i = 0; i < n; ++i)
        {
            scanf("%d", &temp);
            v.emplace_back(temp);
        }
        sort(v.begin() , v.end());
        int counter = 0;
        for (int i = 1; i < v.size(); ++i)
        {
            if (v[i] > v[0])
                counter ++;
        }
        printf("%d\n" , counter);
        v.clear();
    }
    return 0;
}