#include<bits/stdc++.h>
using namespace std;
int q[1000005],w[1000005];
void Sort(int m)
{
for(int l=0;l<m;l++)
{
for(int j=l+1;j<m;j++)
{
if(q[l]>q[j])
{
int r=q[l];
q[l]=q[j];
q[j]=r;
w[l]=1;
w[j]=1;
r=w[l];
w[l]=w[j];
w[j]=r;
}
}
}
}
int main()
{
int n;
cin >> n;
for(int i=0;i<n;i++)
{
int m,x=0;
cin >> m;
for(int l=0;l<m;l++)
{
cin >> q[l];
w[l]=0;
}
Sort(m);
for(int l=0;l<m;l++)
{
if(w[l]==1)
x++;
}
cout << x << endl;
}
return 0;
}