#include <bits/stdc++.h>
using namespace std;

#define ll                     long long int
#define ld                     long double
#define ff                     first
#define ss                     second
#define pb                     push_back
#define pii                    pair <ll , ll>
#define vi                     vector <ll>

#define mii                    map <ll , ll>


#define mod                    1000000007
#define inf                    (ll) (9e18)
#define sp(x , y)              fixed << setprecision(y) << x
#define mk(arr , n , type)     type *arr = new type[n];
#define mar(arr , n , type)    type arr[n];
#define w(x)                   ll x; cin >> x; while(x--)

#define f(i,n)                   for(ll i = 0 ; i < n ; i++)
#define all(p)                 p.begin() , p.end()
#define ub(a , b)              upper_bound(all(a) , b)
#define lb(a , b)              lower_bound(all(a) , b)

#define d(x)                   cerr << #x << " = " << x << endl;

#define fast_io                ios_base::sync_with_stdio(false);                                  cin.tie(NULL);

int main()
{
w(t)
{
   ll n;
   cin>>n;
   vi v(n);
   map<ll,ll> m;
   f(i,n)
   {
       cin>>v[i];
       m[v[i]]++;
   }
   sort(all(v));
   ll ans=n-m[v[0]];
   cout<<ans<<"\n";


}

}