//problem 1

#include <iostream>
#include <bits/stdc++.h>
#define ll long long 

using namespace std;

int main() {
    
    int tt;
    cin >> tt;
    while(tt--){
        
        int n;
        cin >> n;
        vector<int> array(n);
        
        for(int i=0;i<n;i++){
            cin >> array[i];
        }
        
        //end of input
        
        // by chosing a subset of 2 elements, we can eliminate the bigger one
        // so remaining elements will be the minimum valued one
        
        int ans = 0;
        
        int min = array[0];
        for(int i=0;i<n;i++){
            if(array[i] < min){
                min = array[i];
            }
        }
        int freq = 0;
        for(int i=0;i<n;i++){
            if(array[i] == min){
                freq++;
            }
        }
        
        cout << n - freq << endl;
        
    }
    
    
    
}