For this Question: You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.

Return the sum of all the unique elements of nums.first line contains an integer n, that tell about size of array.
then next line line contains n space separated integers.

Constrains:
1<= n <=100000 
1 <= nums[i] <= 1000print the sum of all the unique elements of nums.Sample Input:
4
1 2 3 2

Sample Output:
4

Explanation:The unique elements are (1, 3), and the sum is 4., I have written this Solution Code: import java.util.Scanner;
import java.util.HashMap;

public class Main {

    public int sumOfUnique(Integer[] arr) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            int s = arr[i];
            if(map.containsKey(s))
            map.put(s, map.getOrDefault(s, 0) + 1);
            else map.put(s,1);
        }
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (map.get(arr[i]) == 1)
                count += arr[i];
        }

        return count;

    }

    public static void main(String args[]) {
        int x, n;
        Scanner sc = new Scanner(System.in);
        // System.out.print("Enter the second number: ");
        n = sc.nextInt();
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++) {
            // System.out.print("Enter the first number: ");
            x = sc.nextInt();
            arr[i] = x;
        }
        Main hs = new Main();
        int ans = hs.sumOfUnique(arr);
        System.out.println(ans);
    }

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