#include <bits/stdc++.h>

using namespace std;

int main()
{
   int a;

   cin>>a;

   while(a--)
   {
       int b;

       cin>>b;

       int arr[b];

       for(int j=0;j<b;j++)
        cin>>arr[j];

       sort(arr,arr+b);

       int k=0;
       while(arr[0]==arr[k]&&k<b)
       {
           k++;
       }

       k--;



       cout<<b-(k+1)<<"\n";

   }
}
