#include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
typedef long long ll;


void solve()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
  cin>>a[i];
  ll cnt=0;
  while(1)
  {
    ll n1=0,s=0;
    for(ll i=0;i<n;i++)
    {
      if(a[i]!=-1)
      {
        s+=a[i];
        n1++;
      }
    }
    ll f=0;
    s=s/n1;
    for(ll i=0;i<n;i++)
    {
      if(a[i]!=-1)
      {
        if(a[i]>s)
        {
          a[i]=-1;
          cnt++;
          f=1;
        }
      }
    }
    if(f==0)
      break;
  }
  cout<<cnt<<endl;
}
int  main()
{
  ll t=1;
  cin>>t;
  while(t--)
  solve();
}