#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
const ll N=1e6;
const ll MOD =1e9 + 7 ;
const ll Inf = MOD*MOD;
const ll dx[17] = {0,0,-1,1,1,-1,-1,1,1,-1,2,-2,-1,1,2,-2};
const ll dy[17] = {-1,1,0,0,1,-1,1,-1,2,2,1,1,-2,-2,-1,-1};
ll  n , m  , q , a[N] , prf[N] , L  , R , sol , k  , timer  , x , y , ans  , t = 1 ;
double  w , pi = acos(-1);
bool flag = true ;
string  s = "", s1 = "";
vector<ll>v;
map<int,int>cnt;
deque<char>V[101];
ll fast_pow(ll a,ll p)
{   ll res =  1;
    while(p){
        if(p % 2 == 0){
          a = a * a  % MOD ;
          p = p  / 2;
        }
        else{
            res = res * a % MOD ;
            --p;
        }
    }
   return res;
}
ll Dp(ll i , ll cnt)
{
}
void intialize_data()
{

}
void clear_(){
  //memset(meme,-1,sizeof(meme));
   cnt.clear();
}
 void Solve()
{
     clear_();
     ans = 0 ;
     scanf("%lld",&n);
     for(int i = 1 ; i <= n ; ++i)
     {
         scanf("%lld",&a[i]);
         ++cnt[a[i]];
     }
     for(int i = 1 ; i <= 200 ; ++i)
     cnt[i + 1] += cnt[i];

     for(int i = 1 ; i <= n ; ++i)
     if(cnt[a[i] - 1])++ans;

     cout << ans << "\n";

}
int main(){
    //intialize_data();
    scanf("%lld",&t);
    while(t--)
    {
     ++timer;
      Solve();
    }
}
