/*by : yosef mahmoud
college : ain shams
i will be the greatest Competitive programmer One day !
 */
#include <bits/stdc++.h>
#define loop(x,n) for(int x = 0 ; x<n;x++) //to write 2d arrays faster ,generally arrays use
#define ll long long
const ll mod = 1e9 + 72321;
using namespace std;
#define Speedo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,m,n) for(int i=m; i<n; i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define print(arr,size) for(int i = 0; i<size;i++){cout<<arr[i]<<" ";}cout<<endl;
#define news(f) int f; cin>>f;
#define endl          '\n'
#define return0 return 0
#define Endl endl
ll sum = 0, final = 0, result = 0;
const ll N = 1e6;
#define ull unsigned long long
#define ssort(arr,n) sort(arr,arr+n)
int main()
{

	Speedo;
	int n;
	cin >> n;
    while (n--)
    {
        int n;
        cin >> n;
        int ara[100];
        bool flag = false;
        for (int i = 0; i < n; i++){
            cin >> ara[i];
    }
        sort(ara, ara + n);
        int i;
        for (i = 1; i < n; i++)
        {
            if (ara[i] > ara[i - 1])
            {
                cout << n - i << endl;
                flag = true;
                break;
            }
        }
		if (!flag)
		{
			cout << 0 << endl;
		}

	}
}