Can anyone help me why my code got (WA) ,I did the same as editorial
here is the code
try {
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t–>0){
int n=sc.nextInt();
int a[]=new int[n];
TreeMap<Integer,Integer> mp=new TreeMap<>();
for(int i=0; i<n; i++){
a[i]=sc.nextInt();
mp.put(a[i],mp.getOrDefault(a[i],0)+1);
}
long ans=0;
int cnt=0,c=1;
int size=mp.size();
for(int it: mp.keySet()){
cnt=mp.get(it);
int rmg=n-cnt;
ans+=(long)(rmg*(cnt));
}
System.out.println(ans);
}
} catch(Exception e) {
}