A divisor tree is a rooted tree that meets the following conditions: 

  * Each vertex of the tree contains a positive integer number. 
  * The numbers written in the leaves of the tree are prime numbers. 
  * For any inner vertex, the number within it is equal to the product of the numbers written in its children. 



Manao has n distinct integers a1, a2, ..., an. He tries to build a divisor tree which contains each of these numbers. That is, for each ai, there should be at least one vertex in the tree which contains ai. Manao loves compact style, but his trees are too large. Help Manao determine the minimum possible number of vertices in the divisor tree sought.

Input

The first line contains a single integer n (1 ≤ n ≤ 8). The second line contains n distinct space-separated integers ai (2 ≤ ai ≤ 1012).

Output

Print a single integer — the minimum number of vertices in the divisor tree that contains each of the numbers ai.

Examples

Input

2
6 10


Output

7


Input

4
6 72 8 4


Output

12


Input

1
7


Output

1

Note

Sample 1. The smallest divisor tree looks this way: <image>

Sample 2. In this case you can build the following divisor tree: <image>

Sample 3. Note that the tree can consist of a single vertex.
import java.util.Arrays;
import java.util.TreeMap;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.HashMap;
import java.util.List;
import java.io.BufferedReader;
import java.util.Map;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author shu_mj @ http://shu-mj.com
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskI solver = new TaskI();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskI {
    Scanner in;
    PrintWriter out;
    private int n;
    private long[] ls;
    private int res;
    private List<Long>[] ps;
    private boolean[][] eq;
    private long[] lls;

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        this.in = in;
        this.out = out;
        run();
    }

    void run() {
        Num.primeTable(1000000, new ArrayList<>());
        n = in.nextInt();
        ls = in.nextLongArray(n);
        Arrays.sort(ls);
        lls = ls.clone();
        eq = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                eq[i][j] = ls[i] == ls[j];
            }
        }
        ps = new List[n];
        for (int i = 0; i < n; i++) {
            ps[i] = Num.primeFactors(ls[i]);
        }
        pre = new int[n];
        Arrays.fill(pre, -1);
        res = Integer.MAX_VALUE;
        dfs(0);
        out.println(res);
    }

    private void dfs(int crt) {
        if (crt == n) {
            long[] cs = ls.clone();
            int cnt = 0;
            boolean[] leaf = new boolean[n];
            Arrays.fill(leaf, true);
            boolean f = false;
            for (int i = 0; i < n; i++) {
                if (pre[i] != -1) leaf[pre[i]] = false;
                if (i < n - 1 && pre[i] == -1) f = true;
                if (Num.isPrime(ls[i]) && leaf[i]) {
                    continue;
                }
                for (long p : ps[i]) {
                    if (p * p > cs[i]) break;
                    if (cs[i] % p == 0) {
                        while (cs[i] % p == 0) {
                            cs[i] /= p;
                            cnt++;
                        }
                    }
                }
                if (cs[i] != 1) cnt++;
            }
            if (f) cnt++;
//            if (cnt + n == 11) {
//                Algo.debug(ls);
//                Algo.debug(pre);
//            }
            res = Math.min(res, cnt + n);
        } else {
            for (int i = crt + 1; i < n; i++) {
                if (ls[i] % lls[crt] == 0 && !eq[crt][i]) {
                    pre[crt] = i;
                    ls[i] /= lls[crt];
                    dfs(crt + 1);
                    ls[i] *= lls[crt];
                    pre[crt] = -1;
                }
            }
            dfs(crt + 1);
        }
    }

    int[] pre;

}

class Scanner {
    BufferedReader br;
    StringTokenizer st;

    public Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null)
                return false;
            eat(s);
        }
        return true;
    }

    public String next() {
        hasNext();
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public long[] nextLongArray(int n) {
        long[] ls = new long[n];
        for (int i = 0; i < n; i++) {
            ls[i] = nextLong();
        }
        return ls;
    }

}

class Num {
    public static Random rnd;
    public static List<Integer> primes;
    public static boolean[] isPrime;

    public static boolean millerRabin(BigInteger n, int times) {
        n = n.abs();
        if (n.compareTo(BigInteger.valueOf(2)) < 0) return false;
        if (n.equals(BigInteger.valueOf(2))) return true;
        if (!n.testBit(0)) return false;
        BigInteger q = n.subtract(BigInteger.ONE);
        int k = 0;
        while (q.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) {
            k++;
            q = q.shiftRight(1);
        }
        for (int i = 0; i < times; i++) {
            BigInteger a = new BigInteger(n.bitLength(), rnd == null ? rnd = new Random() : rnd).abs().mod(n.subtract(BigInteger.ONE)).add(BigInteger.ONE);
            BigInteger x = a.modPow(q, n);
            if (x.equals(BigInteger.ONE)) continue;
            boolean found = false;
            for (int j = 0; j < k; j++) {
                if (x.equals(n.subtract(BigInteger.ONE))) {
                    found = true;
                    break;
                }
                x = x.multiply(x).mod(n);
            }
            if (found) continue;
            return false;
        }
        return true;
    }

    public static boolean isPrime(long n) {
        if (isPrime != null && n < isPrime.length) return isPrime[(int) n];
        return millerRabin(BigInteger.valueOf(n), 10);
    }

    public static boolean[] primeTable(int n, List<Integer> primes) {
        Num.primes = primes;
        isPrime = new boolean[n + 1];
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        /*
        for (int i = 2; i <= n; i++) {
            if (isPrime[i]) primes.R(i);
            for (int p : primes) {
                if (i > n / p) break;
                isPrime[i * p] = false;
                if (i % p == 0) break;
            }
        }*/
        for (int i = 2; i <= n; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i + i; j <= n; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        return isPrime;
    }

    public static List<Long> primeFactors(long n) {
        List<Long> ps = new ArrayList<Long>();
        for (int i : primes) {
            if ((long) i * i > n) break;
            if (n % i == 0) {
                ps.add((long) i);
                while (n % i == 0) n /= i;
            }
        }
        if (n != 1) ps.add(n);
        return ps;
    }

}

	  	 	   		  				  	 	  	   			