For this Question: Given an array of N elements, your task is to find the count of repeated elements. Print the repeated elements in ascending order along with their frequency.
Have a look at the example for more understanding.The first line of input contains a single integer N, the next line of input contains N space- separated integers depicting the values of the array.

Constraints:-
1 <= N <= 100000
1 <= Arr[i] <= 100000For each duplicate element in sorted order in a new line, First, print the duplicate element and then print its number of occurence space- separated.

Note:- It is guaranteed that at least one duplicate element will exist in the given array.Sample Input:-
5
3 2 1 1 2

Sample Output:-
1 2
2 2

Sample Input:-
5
1 1 1 1 5

Sample Output:-
1 4

Explaination:
test 1: Only 1 and 2 are repeated. Both are repeated twice. So, we print:
1 -> frequency of 1
2 -> frequency of 2
1 is printed before 2 as it is smaller than 2, I have written this Solution Code: import java.io.*;
import java.util.*;



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

        InputStreamReader read = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(read);

        int noOfElements = Integer.parseInt(in.readLine());
        String [] elem = in.readLine().trim().split(" ");

        int [] elements = new int [noOfElements];
        for(int i=0 ; i< noOfElements; i++){
            elements[i] = Integer.parseInt(elem[i]);
        }

        Arrays.sort(elements);
        int count =0;
        for(int i = 0 ; i < noOfElements-1 ; i++){
            if(elements[i] == elements[i+1]){
                    count ++;
            }
            else if(count != 0){
                System.out.print(elements[i]+" "+(count+1));
                count =0;
                System.out.println();
            }

        }
        if(count != 0)
            System.out.print(elements[noOfElements-1]+" "+(count+1));
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?