For this Question: Given an integer array A of size N. Find the sum of GCD (Greatest Common Divisor) of all elements with their frequency.First line contains an integers N.
Next line contains N space separated integers denoting elements of array.

Constraints
1 <= N <= 1000
0 <= Ai<= 10^5Print the sum of GCD of all elements with their frequency.Sample Input 1:
3
1 2 3

Output 
3

Explanation:
gcd(1, 1) + gcd(2, 1) + gcd(3, 1) = 1+1+1 = 3

Sample Input 2:
6
3 6 6 9 3 3

Output 
14

Explanation
gcd(3, 3) + gcd(6, 2) + gcd(6, 2) + gcd(9, 1) + gcd(3, 3) + gcd(3, 3)= 3+2+2+1+3+3= 14, I have written this Solution Code: import java.io.*;
import java.util.*;
import java.math.BigInteger;  

class  Main {
    static int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int [n];
		Map<Integer,Integer>m=new HashMap<Integer, Integer>();
		for(int i=0;i<n;i++){
		    a[i]=sc.nextInt();
		}
		int sum=0;
		for(int i=0;i<n;i++) {
		     if (m.containsKey(a[i])) m.put(a[i], m.get(a[i]) + 1);
            else m.put(a[i], 1);
	    }
	    for(int i=0;i<n;i++) {
		    sum += gcd(a[i],m.get(a[i]));
	    }
	    System.out.print(sum);
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?