#include <bits/stdc++.h>
using namespace std;
vector<int> v[10];
int T[10], K, pr[10], b[10][10100], nrp, cs, sol, sc, n, c[10][10100],
    d[10][10100], vi[10];
map<long long, int> viz;
long long a[10100];
void dfs(int x) {
  vi[x] = 1;
  for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); it++) {
    if (vi[*it]) {
      K = 0;
      break;
    }
    dfs(*it);
  }
}
void df(int x) {
  for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); it++) df(*it);
  for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); it++) {
    for (int j = 1; j <= nrp; ++j) d[x][j] -= b[*it][j];
  }
}
void back(int k) {
  if (k > n) {
    K = 1;
    memset(vi, 0, sizeof(vi));
    for (int j = 0; j <= n; ++j) v[j].clear();
    for (int j = 1; j <= n; ++j) v[T[j]].push_back(j);
    if (T[1] == 5 && T[2] == 5 && T[3] == 7) {
      K++;
      K--;
    }
    dfs(0);
    for (int j = 0; j <= n; ++j)
      if (!vi[j]) K = 0;
    if (!K) return;
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= nrp; ++k) d[j][k] = c[j][k];
    df(0);
    K = 1;
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= nrp; ++k)
        if (d[j][k] < 0) K = 0;
    if (!K) return;
    cs = 0;
    for (int i = 1; i <= n; ++i)
      if (pr[i] && v[i].size() == 0) {
        for (int j = 1; j <= nrp; ++j) d[i][j] = 0;
      }
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= nrp; ++k) cs += d[j][k];
    cs += n;
    if (v[0].size() > 1) ++cs;
    sol = min(sol, cs);
    return;
  }
  for (int i = 0; i <= n; ++i)
    if (i != k && a[i] % a[k] == 0) {
      T[k] = i;
      back(k + 1);
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    long long x = a[i];
    for (int j = 2; 1LL * j * j <= x; j++)
      if (x % j == 0) {
        if (!viz[j]) viz[j] = ++nrp;
        while (x % j == 0) {
          x /= j;
          b[i][viz[j]]++;
        }
      }
    if (x != 1) {
      if (!viz[x]) viz[x] = ++nrp;
      b[i][viz[x]]++;
    }
    for (int j = 1; j <= nrp; ++j) c[i][j] = b[i][j];
    if (x == a[i]) pr[i] = 1;
  }
  sol = (1 << 30);
  back(1);
  cout << sol;
  return 0;
}
