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;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
const int MAGIC = 16;
int dp[1 << MAGIC], n;
long long a[8];
int cnt[8];
vector<int> adjList[8];
int process(long long num) {
  long long t_num = num;
  int ret = 0;
  for (long long i = 2; i * i <= num; ++i) {
    while (num % i == 0) {
      num /= i;
      ++ret;
    }
  }
  if (num > 1) ++ret;
  return ret;
}
bool oka(int mask) {
  for (int i = 0; i < n; ++i)
    if (!checkBit(mask, i)) return false;
  return true;
}
bool oka2(int mask) {
  int ret = 0;
  for (int i = n; i < n + n; ++i) {
    if (!checkBit(mask, i)) ++ret;
  }
  return ret > 1;
}
int func(int mask) {
  if (oka(mask)) return oka2(mask);
  int &ret = dp[mask];
  if (ret != -1) return ret;
  ret = inf;
  for (int i = 0; i < n; ++i) {
    if (checkBit(mask, i)) continue;
    vector<int> store;
    int tret = cnt[i];
    if (tret != 1) ++tret;
    for (auto j : adjList[i]) {
      if (checkBit(mask, n + j)) continue;
      store.emplace_back(j);
    }
    for (int j = 0; j < (1 << store.size()); ++j) {
      long long tmp = 1;
      int sum = 0;
      int tmask = setBit(mask, i);
      for (int k = 0; k < store.size(); ++k) {
        if (checkBit(j, k)) {
          if (a[i] / tmp < a[store[k]]) {
            tmp = a[i] + 1;
            break;
          }
          tmp *= a[store[k]];
          sum += cnt[store[k]];
          tmask = setBit(tmask, n + store[k]);
        }
      };
      ;
      if (a[i] % tmp != 0) continue;
      ret = min(ret, tret - sum + func(tmask));
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cnt[i] = process(a[i]);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[i] % a[j] == 0)
        adjList[i].emplace_back(j);
      else if (a[j] % a[i] == 0)
        adjList[j].emplace_back(i);
    }
  }
  memset(dp, -1, sizeof(dp));
  int ans = func(0);
  cout << ans << '\n';
  return 0;
}
