/**
 *   author:  ks3rr
 *   created: shiva.shiva.shiva krishna:krishna:krishna
 *   Jai Shree Radha Krishna!
**/
#include "bits/stdc++.h"

using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
ld pi = 3.141592653589793238;
#define nl cout << "\n";
#define pll pair<ll, ll>
#define eb emplace_back
#define pb push_back
#define xINF 2000000000
const ll INF = ll(2e18);
#define xmod 1000000007
#define xmod2 998244353
#ifndef ONLINE_JUDGE
  #define xd(x) cout << #x << " = " << x << endl;
#else
  #define xd(x) 5;
#endif
ll mo(const ll input, const ll ceil)
{
  return input >= ceil ? input % ceil : input;
}

void solve(int tc)
{
  ll n;
  cin>>n;
  vector<ll>a(n+5,0);
  map<ll,ll>mp;
  ll mina=INF;
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i];
    mina=min(mina,a[i]);
    mp[a[i]]++;
  }
  cout<<n-mp[mina]<<"\n";
}

signed main()
{
  fio
  int tt = 1;
  cin>>tt;
  for (int i = 0; i < tt; i++)
  {
    solve(i + 1);
  }
  return 0;
}
