#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
long long aa[N + 2], bb[N + 2], n, mn;
map<long long, long long> mm;
long long abc(long long n) {
  if (mm.find(n) != mm.end()) return mm[n];
  long long str = n;
  long long sq = sqrt(n + 1), cnt = 0;
  for (long long i = 2; i <= sq; i++) {
    while (n % i == 0) cnt++, n /= i;
  }
  if (n > 1) cnt++;
  return mm[str] = cnt;
}
void dfs(long long st, vector<long long> rt, long long ans) {
  if (st > n) {
    if (rt.size() > 1) ans++;
    mn = min(mn, ans);
    return;
  }
  long long ii = abc(aa[st]);
  if (ii == 1) {
    vector<long long> tmp = rt;
    tmp.push_back(aa[st]);
    dfs(st + 1, tmp, ans + 1);
  } else {
    long long sz = rt.size(), cnt = 0;
    for (long long i = 0; i < (1LL << sz); i++) {
      long long x = aa[st];
      vector<long long> tmp;
      for (long long j = 0; j < sz; j++) {
        if ((i & (1LL << j)) && (x % rt[j] == 0))
          x /= rt[j];
        else
          tmp.push_back(rt[j]);
      }
      tmp.push_back(aa[st]);
      if (x == aa[st]) {
        if (!cnt) dfs(st + 1, tmp, ans + abc(x) + 1);
        cnt++;
      } else
        dfs(st + 1, tmp, ans + abc(x) + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> aa[i];
  sort(aa + 1, aa + n + 1);
  vector<long long> rt;
  mn = 1e9;
  dfs(1, rt, 0);
  cout << mn << endl;
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6;
long long aa[N + 2], bb[N + 2], n, mn;
map<long long, long long> mm;
long long abc(long long n) {
  if (mm.find(n) != mm.end()) return mm[n];
  long long str = n;
  long long sq = sqrt(n + 1), cnt = 0;
  for (long long i = 2; i <= sq; i++) {
    while (n % i == 0) cnt++, n /= i;
  }
  if (n > 1) cnt++;
  return mm[str] = cnt;
}
void dfs(long long st, vector<long long> rt, long long ans) {
  if (st > n) {
    if (rt.size() > 1) ans++;
    mn = min(mn, ans);
    return;
  }
  long long ii = abc(aa[st]);
  if (ii == 1) {
    vector<long long> tmp = rt;
    tmp.push_back(aa[st]);
    dfs(st + 1, tmp, ans + 1);
  } else {
    long long sz = rt.size(), cnt = 0;
    for (long long i = 0; i < (1LL << sz); i++) {
      long long x = aa[st];
      vector<long long> tmp;
      for (long long j = 0; j < sz; j++) {
        if ((i & (1LL << j)) && (x % rt[j] == 0))
          x /= rt[j];
        else
          tmp.push_back(rt[j]);
      }
      tmp.push_back(aa[st]);
      if (x == aa[st]) {
        if (!cnt) dfs(st + 1, tmp, ans + abc(x) + 1);
        cnt++;
      } else
        dfs(st + 1, tmp, ans + abc(x) + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> aa[i];
  sort(aa + 1, aa + n + 1);
  vector<long long> rt;
  mn = 1e9;
  dfs(1, rt, 0);
  cout << mn << endl;
  return 0;
}

```