For this Question: You are given an array A of size N. The array contains almost distinct elements with some duplicated. You have to print the elements in sorted order which appears more than once.The first line of input contains T, denoting the number of testcases. T testcases follow. Each testcase contains two lines of input.  The first line of input contains size of array N. The second line contains N integers separated by spaces.


Constraints:
1 <= T <= 100
1 <= N <= 100000
0 <= A<sub>i</sub> <= 100000

Sum of N over all test cases do not exceed 100000For each test case, in a new line, print the required answer in separate line. If there are no duplicates print -1.Input:
1
9
3 4 5 7 8 1 2 1 3

Output:
1 3
 Explanation : both 1,3 appeared 2 times 

Input
1
5
1 2 3 4 5

Output
-1

, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException {

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=Integer.parseInt(br.readLine());
        String nums[];
        int n;
        TreeMap<Integer,Integer> tm=null;
        int m,p;
        boolean flag;
        for(int a=0;a<t;++a)
        {
            n=Integer.parseInt(br.readLine());
            nums=br.readLine().split("\\s");
            tm=new TreeMap<>();
            for(int i=0;i<n;++i)
            {
                p=Integer.parseInt(nums[i]);
                tm.put(p,tm.getOrDefault(p,0)+1);
            }
            flag=false;
            for(Integer i:tm.keySet())
            {
                m=tm.get(i);
                if(m>1)
                {
                    System.out.print(i+" ");
                    flag=true;
                }
            }
            if(!flag)
            {
                System.out.println(-1);
            }
            else System.out.println();
        }

	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?