Help me in solving EQUALELE problem

My issue

My code

#include <iostream>
#include<algorithm>
using namespace std;

int main() {
	// your code goes here
		int t,i;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[n];
	    for(i=0;i<n;i++)
	    {
	        cin>>a[i];
	    }
	    int count=0;
	    
	    sort(a,a+n);
	    for(i=0;i<n;i++){
	        if(a[i]==a[i+1])
	        {
	        count++;
	        }
	    }
	    cout<<n-1-count<<endl;
	    
	}
	return 0;
}

Problem Link: EQUALELE Problem - CodeChef

@kjha1893
Have corrected your code . u are not tracking the count of maximum freq.
include
include
using namespace std;

int main() {
// your code goes here
int t,i;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
}
int count=1;

    sort(a,a+n);
    int ans=0;
    
    for(i=1;i<n;i++){
        if(a[i]==a[i-1])
        {
        count++;
        }
        else
        {
            ans=max(ans,count);
            count=1;
        }
    }
    ans=max(ans,count);
    cout<<n-ans<<endl;
    
}
return 0;

}

thank you

can u give me some example taste case which cant be true in my code pls