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.*;
import java.io.*;
import java.math.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	class Pair {
		
		long div;
		int cnt;
		
		public Pair(long div, int cnt) {
			this.div = div;
			this.cnt = cnt;
		}
		
	}
	
	ArrayList<Pair> f [];
	
	ArrayList<Pair> merge (ArrayList<Pair> a, ArrayList<Pair> b) {
		ArrayList<Pair> result = new ArrayList<>();
		int j = 0;
		for (int i = 0; i < a.size(); i++) {
			while (j < b.size() && b.get(j).div < a.get(i).div) {
				result.add(b.get(j));
				j++;
			}
			if (j < b.size() && b.get(j).div == a.get(i).div) {
				result.add(new Pair (b.get(j).div, b.get(j).cnt + a.get(i).cnt));
				j++;
			} else {
				result.add(a.get(i));
			}
		}
		for (int i = j; i < b.size(); i++) {
			result.add(b.get(i));
		}
		return result;
	}
	
	int divide (ArrayList<Pair> a, ArrayList<Pair> b) {
		int result = 0;
		int j = 0;
		for (int i = 0; i < b.size(); i++) {
			while (j < a.size() && a.get(j).div < b.get(i).div) {
				result += a.get(j).cnt;
				j++;
			}
			if (j < a.size() && a.get(j).div == b.get(i).div) {
				if (a.get(j).cnt < b.get(i).cnt)
					return -1;
				result += a.get(j).cnt - b.get(i).cnt;
				j++;
			} else {
				return -1;
			}
 		}
		for (int i = j; i < a.size(); i++) {
			result += a.get(i).cnt;
		}
		return result;
	}
	
	public void solve() throws Throwable {
		int n = sc.nextInt();
		long numbers [] = new long [n];
		for (int i = 0; i < n; i++)
			numbers[i] = sc.nextLong();
		Arrays.sort(numbers);
		
		f = new ArrayList [n];
		for (int k = 0; k < n; k++) {
			f[k] = new ArrayList<>();
			long num = numbers[k];
			for (long i = 2; i * i <= num; i++) {
				if (num % i == 0) {
					int cnt = 0;
					while (num % i == 0) {
						num /= i;
						cnt++;
					}
					f[k].add(new Pair(i, cnt));
				}
			}
			if (num > 1)
				f[k].add(new Pair (num, 1));
		}
		
		int dp [][] = new int [n + 1][(1 << n)];
		for (int i = 0; i <= n; i++)
			Arrays.fill(dp[i], Integer.MAX_VALUE / 2);
		
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int mask = 0; mask < (1 << i); mask++) {
				if (dp[i][mask] == Integer.MAX_VALUE / 2) continue;
				
				for (int submask = 0; submask < (1 << i); submask++) {
					if ((mask & submask) != submask) continue;
					
					ArrayList<Pair> mergeResult = new ArrayList<>();
					for (int j = 0; j < i; j++) {
						if (((1 << j) & submask) != 0)
							mergeResult = merge (mergeResult, f[j]);
					}
					
					
					int res = divide(f[i], mergeResult);
					if (res != -1) {
						if (submask != 0)
							dp[i + 1][(mask | (1 << i)) ^ submask] = min (dp[i + 1][(mask | (1 << i)) ^ submask], dp[i][mask] + res + 1);
						else
							dp[i + 1][mask | (1 << i)] = min (dp[i + 1][mask | (1 << i)], dp[i][mask] + res + (res > 1 ? 1 : 0));
					}
				}
			}
		}
		
		int answer = Integer.MAX_VALUE / 2;
		
		for (int mask = 0; mask < (1 << n); mask++) {
			answer = min (answer, dp[n][mask] + (Integer.bitCount(mask) > 1 ? 1 : 0));
		}
		
		out.println(answer);
	}
	

	static Throwable t;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable t) {
			Solution.t = t;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", 1 << 26);
		thread.start();
		thread.join();
		if (Solution.t != null)
			throw t;
	}

}

class FastScanner {

	BufferedReader in;
	StringTokenizer st;

	public FastScanner(BufferedReader in) {
		this.in = in;
	}

	public String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

}