#include <bits/stdc++.h>
using namespace std;
const int maxn = 8, inf = 1000000000;
int n, p[maxn], order[maxn], ans = inf;
long long data[maxn];
vector<long long> fact[maxn], tmp[maxn];
inline int matchSubseq(vector<long long> &a, vector<long long> &b) {
  for (size_t i = 0, ptr = 0; i < a.size(); i++, ptr++) {
    while (ptr < b.size() && b[ptr] != a[i]) ptr++;
    if (ptr >= b.size()) return -1;
  }
  return b.size() - a.size();
}
void rec(int k) {
  if (k == n) {
    int curans = 0, alone = 0;
    for (int i = 0; i < n; i++) tmp[i].clear();
    for (int i = n - 1; i >= 0; i--) {
      int v = order[i];
      sort(tmp[i].begin(), tmp[i].end());
      int x = matchSubseq(tmp[i], fact[v]);
      if (x == -1) return;
      if (fact[v].size() == 1)
        curans++;
      else
        curans += x + 1;
      if (p[i] == -1)
        alone++;
      else
        for (size_t j = 0; j < fact[v].size(); j++)
          tmp[p[i]].push_back(fact[v][j]);
    }
    if (alone > 1) curans++;
    ans = min(ans, curans);
    return;
  }
  for (p[k] = -1; p[k] < k; p[k]++) rec(k + 1);
}
inline bool cmp(int a, int b) { return fact[a].size() > fact[b].size(); }
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
    long long tmp = data[i];
    for (long long x = 2; x * x <= tmp; x++)
      while (tmp % x == 0) tmp /= x, fact[i].push_back(x);
    if (tmp != 1) fact[i].push_back(tmp);
    order[i] = i;
  }
  sort(order, order + n, cmp);
  rec(0);
  printf("%d\n", ans);
  return 0;
}
