Help me in solving PAIREQ problem

My issue

My code

import java.lang.*;
import java.io.*;
import java.util.*;
class Codechef
{
        public void main(String[] args) throws java.lang.Exception
        {
            Scanner kb  = new Scanner(System.in);
		int t = kb.nextInt();
		while(t-->0)
		{
		    int n = kb.nextInt();
		    int a [] = new int[n];
		    for(int i=0;i<n;i++)
		    {
		        a[i] = kb.nextInt();
		    }
		    Arrays.sort(a);
		    int Mcount = 0;
		    
		    for(int i = 0;i<n-1;i++)
		    {
		        int c = 0;
		        for(int j=0;j<n;j++)
		        {
		            if(a[i] == a[j])
		            {
		                c++;
		            }
		        }
		        if(c>Mcount)
		        {
		            Mcount=c;
		        }
		    }
		    System.out.println(n - Mcount);
		}
        }
}

Problem Link: PAIREQ Problem - CodeChef

@viru_1234
Have corrected your code just typing mistake.

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		 Scanner kb  = new Scanner(System.in);
		int t = kb.nextInt();
		while(t-->0)
		{
		    int n = kb.nextInt();
		    int a [] = new int[n];
		    for(int i=0;i<n;i++)
		    {
		        a[i] = kb.nextInt();
		    }
		    Arrays.sort(a);
		    int Mcount = 0;
		    
		    for(int i = 0;i<n;i++)
		    {
		        int c = 0;
		        for(int j=0;j<n;j++)
		        {
		            if(a[i] == a[j])
		            {
		                c++;
		            }
		        }
		        if(c>Mcount)
		        {
		            Mcount=c;
		        }
		    }
		    System.out.println(n - Mcount);
		}
	}
}