#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
#define int long long
const int maxn = 1e6 + 10;
int read(){
  int x=0;
  int f=1;
  char ch=getchar();
  while(ch<'0'||ch>'9'){
    if(ch=='-')
    f=-1;
    ch=getchar();
  }
  while(ch>='0'&&ch<='9'){
    x=x*10+ch-'0';
    ch=getchar();
  }
  return x*f;
}
int T;
int n;
int a[maxn];
map<int, bool>Map;

signed main(){
  T = read();
  while(T--){
    n = read();
    for(int i = 1; i <= n; i++){
      a[i] = read();
      
    }
    int ans = 0;
    int minn = 0x3f3f3f3f;
    for(int i = 1; i <= n; i++){
      minn = min(minn, a[i]);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
      if(minn == a[i]){
        cnt++;
      }
    }
    ans = (n - cnt);
    cout << ans << endl;


  }
}