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;
inline int oceni(long long a) {
  int ret = 0;
  long long dv = 2;
  while (dv * dv <= a) {
    while (a % dv == 0) {
      ret++;
      a /= dv;
    }
    dv++;
  }
  if (a > 1) ret++;
  return ret;
}
long long brs[10];
int cena[10];
int gate[10][1 << 10];
int n;
int sol[20000];
int cur[10];
int nov[10];
inline int sredi(void) {
  int ret = 0;
  for (int i = n; i >= 0; i--) ret = ret * 3 + nov[i];
  return ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> brs[i];
  sort(brs, brs + n);
  for (int i = 0; i < n; i++) cena[i] = oceni(brs[i]);
  for (int gl = 0; gl < n; gl++)
    for (int mask = 1; mask < 1 << n; mask++) {
      long long fus = brs[gl];
      int ok = 1;
      for (int i = 0; i < n; i++)
        if (mask & (1 << i))
          if (i != gl) {
            if (fus % brs[i] == 0)
              fus /= brs[i];
            else
              ok = 0;
          } else
            ok = 0;
      gate[gl][mask] = ok;
    }
  for (int i = 1; i < 10005; i++) sol[i] = 100000;
  int st = -1;
  int cp;
  int resenje = 100000;
  for (int i = 0; i < n; i++) gate[i][0] = 1;
  while (1) {
    st++;
    cp = st;
    for (int i = 0; i <= n; i++) {
      cur[i] = cp % 3;
      cp /= 3;
    }
    if (cur[n]) break;
    for (int add = 0; add < n; add++)
      if (cur[add] == 0)
        for (int pick = 0; pick < 1 << n; pick++)
          if (gate[add][pick]) {
            int is1 = 1;
            for (int i = 0; i < n; i++)
              if (pick & (1 << i))
                if (cur[i] != 1) is1 = 0;
            if (is1) {
              int nsd = sol[st] + cena[add] + (cena[add] > 1 ? 1 : 0);
              for (int i = 0; i < n; i++)
                if (pick & (1 << i)) nsd -= cena[i];
              for (int i = 0; i < n; i++) nov[i] = cur[i];
              nov[add] = 1;
              for (int i = 0; i < n; i++)
                if (pick & (1 << i)) nov[i] = 2;
              int gde = sredi();
              sol[gde] = min(sol[gde], nsd);
            }
          }
    int kc = 0;
    int nl = 0;
    for (int i = 0; i < n; i++) {
      if (cur[i] == 0) nl++;
      if (cur[i] == 1) kc++;
    }
    if (nl == 0) {
      int ofr = sol[st];
      if (kc > 1) ofr++;
      if (ofr < resenje) resenje = ofr;
    }
  }
  printf("%d\n", resenje);
}
