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.
#include <bits/stdc++.h>
using namespace std;
long long int n, a[10], sr[256], leaves[10], bpp[256], ispr[12];
const long long int inf = (long long int)1e12;
long long int ans[256][256];
bool pos[256][256];
bool cmp(long long int a, long long int b) {
  long long int ba = bpp[(a)];
  long long int bb = bpp[(b)];
  if (ba != bb) return ba < bb;
  return a < b;
}
bool prime[1000005];
vector<long long int> primes;
void pre() {
  for (long long int p = 2; p <= 1000000; ++p)
    if (!prime[p]) {
      primes.push_back(p);
      for (long long int i = p * 2; i <= 1000000; i += p) prime[i] = 1;
    }
  for (long long int i = 1; i <= n; ++i) {
    long long int v = a[i];
    if (v <= 1000000 && prime[v] == 0) {
      ispr[i] = 1;
      continue;
    }
    for (long long int p : primes) {
      while (v % p == 0) {
        leaves[i]++;
        v /= p;
      }
    }
    if (v > 1 && leaves[i])
      leaves[i]++;
    else if (v > 1)
      ispr[i] = 1;
  }
}
inline long long int getbpp(long long int mask) {
  long long int ret = 0;
  for (long long int i = 0; i <= n - 1; ++i)
    if (mask & (1 << i)) {
      if (!ispr[i + 1]) ret++;
    }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long int i = 1; i <= n; ++i) cin >> a[i];
  pre();
  for (long long int i = 0; i <= (1 << n) - 1; ++i)
    sr[i] = i, bpp[i] = __builtin_popcountll(i);
  sort(sr, sr + (1 << n), cmp);
  for (long long int jj = 1; jj <= (1 << n) - 1; ++jj) {
    long long int mask = sr[jj];
    for (long long int sub = 1; sub <= (1 << n) - 1; ++sub) {
      if ((sub | mask) != mask) continue;
      if (sub == mask)
        pos[mask][sub] = 1;
      else if (bpp[(sub)] == 1) {
        long long int rem = mask ^ sub;
        long long int subelem;
        for (long long int i = 0; i <= n - 1; ++i)
          if (sub & (1 << i)) subelem = a[i + 1];
        bool notpos = 0;
        for (long long int i = 0; i <= n - 1; ++i)
          if (rem & (1 << i)) {
            if (subelem % a[i + 1]) {
              notpos = 1;
              break;
            }
          }
        if (notpos) continue;
        for (long long int subb = 1; subb <= (1 << n); ++subb)
          if ((subb | rem) == rem) {
            long long int prod = 1;
            for (long long int i = 0; i <= n - 1; ++i)
              if (subb & (1 << i)) {
                long long int divi = inf / prod;
                if (a[i + 1] > divi)
                  prod = inf + 1;
                else
                  prod *= a[i + 1];
              }
            if (subelem % prod) continue;
            pos[mask][sub] |= pos[rem][subb];
          }
      } else {
        long long int rem = mask ^ sub;
        long long int subelemfirst;
        for (long long int i = 0; i <= n - 1; ++i)
          if (sub & (1 << i)) {
            subelemfirst = (1 << i);
            break;
          }
        for (long long int subb = 0; subb <= (1 << n); ++subb)
          if ((subb | rem) == rem) {
            pos[mask][sub] |=
                (pos[subelemfirst ^ subb][subelemfirst] &
                 pos[sub ^ subelemfirst + rem ^ subb][sub ^ subelemfirst]);
          }
      }
    }
  }
  for (long long int jj = 1; jj <= (1 << n) - 1; ++jj) {
    long long int mask = sr[jj];
    for (long long int sub = 1; sub <= (1 << n) - 1; ++sub) {
      ans[mask][sub] = 1e18;
      if ((sub | mask) != mask || (!pos[mask][sub])) continue;
      if (sub == mask) {
        long long int tot = 0;
        for (long long int i = 0; i <= n - 1; ++i)
          if (mask & (1 << i)) tot += leaves[i + 1];
        ans[mask][sub] = min(ans[mask][sub], tot + bpp[(mask)]);
      } else if (bpp[(sub)] == 1) {
        long long int subelem;
        for (long long int i = 0; i <= n - 1; ++i)
          if (sub & (1 << i)) subelem = i + 1;
        ans[mask][sub] = min(ans[mask][sub], leaves[subelem] + getbpp((mask)));
      } else {
        long long int rem = mask ^ sub;
        long long int subelemfirst, tot;
        for (long long int i = 0; i <= n - 1; ++i)
          if (sub & (1 << i)) {
            subelemfirst = (1 << i);
            tot = leaves[i + 1] + 1;
            break;
          }
        for (long long int subb = 0; subb <= (1 << n); ++subb)
          if ((subb | rem) == rem) {
            if (pos[subelemfirst ^ subb][subelemfirst]) {
              ans[mask][sub] = min(
                  ans[mask][sub],
                  tot + getbpp((subb)) +
                      ans[sub ^ subelemfirst + rem ^ subb][sub ^ subelemfirst]);
            }
          }
      }
    }
  }
  long long int mi = ans[(1 << n) - 1][1];
  for (long long int sub = 1; sub <= (1 << n) - 1; ++sub) {
    if (bpp[sub] > 1) ans[(1 << n) - 1][sub]++;
    mi = min(mi, ans[(1 << n) - 1][sub]);
  }
  cout << mi << '\n';
}
