#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
typedef long long ll;
typedef long double ld;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const long double PI = acos(-1);
#define mp make_pair
#define all(v) v.begin(), v.end()
#define F first
#define S second
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<vi> vvi;

 //debugger
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// debugger end
//global variables


//functions
void solve()
{
  int n;
  cin>>n;
  vi arr;int temp;
  int i;
  
  rep(i,0,n)
  {
    cin>>temp;
    arr.pb(temp);
  }
  sort(all(arr));
  int freq=0;
  rep(i,0,n)
  {
    if(arr[i]==arr[0])
    {
      freq++;
    }
  }
  cout<<n-freq<<endl;
} 

int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
    int test;
   cin>>test;
   while(test--)
   {
       solve();
    }
 



 return 0;
}