Find the Error

//https://www.codechef.com/JUNE222D/problems/PAIREQ
#include<bits/stdc++.h>
#include
using namespace std;

int main() {
// your code goes herei
int t;
cin>>t;
for(int i=0;i<t;i++){
int n;
cin>>n;
vectora;
for(int j=0;j<n;j++)
sort(a.begin(),a.end(){
int t;
cin>>t;
a.push_back(t);
};
int k=1,max=0;
for(int j=0;j<n-1;j++){
if(a[j]==a[j+1])
k++;
else{
if(k>=max){
max=k;
k=1;
}
}
}
cout<<n-max<<endl;
}
return 0;
}