For this Question: <b><em>Array List In Java</em></b>

There is a list, having n integers that may have duplicates, is given. Write a Java program to print all unique elements and their frequencies. Elements must be in sorted order.There is an integer n is given in first line of input.
In Second line, n space separated integers are given.

<b>Constraints</b>
1 <= n <= 10<sup>4</sup>Print all unique elements and their frequencies. Elements must be in sorted order.Sample Input:
7
1 2 4 3 5 4 3

Sample Output:
1 1
2 1
3 2
4 2
5 1, I have written this Solution Code: import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Map<Integer,Integer> mp = new HashMap<>();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (mp.get(a)!=null) {
        mp.put(a, mp.get(a) + 1);
      } else
        mp.put(a, 1);
    }

    for (Map.Entry<Integer, Integer> entry : mp.entrySet()) {
      System.out.print(entry.getKey());
      System.out.print(" ");
      System.out.println(entry.getValue());
    }
    return;
  }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?