#include <bits/stdc++.h>
using namespace std;
long long mul(long long a, long long b) {
  if (a >= (1e13) / (1.0 * b)) return 1e13;
  return a * b;
}
int cnt[(1 << 8)], n;
long long arr[8], ml[1 << 8], p3[8];
long long memo[7000], lg[1 << 8];
int v[8];
long long solve(long long num, int m) {
  int c0 = 0, c1 = 0;
  for (int i = 0; i < n; ++i)
    if (!v[i])
      c0++;
    else if (v[i] == 1)
      c1++;
  if (!c0 && c1 > 1) return 1;
  if (!c0 && c1 == 1) return 0;
  long long &ret = memo[num];
  if (~ret) return ret;
  ret = 1e18;
  for (int i = 0; i < n; ++i) {
    if (v[i]) continue;
    for (int sm = m, lmm = -1; lmm;
         lmm = (sm & -sm), sm = (sm - lmm) | (m & (lmm - 1))) {
      if (arr[i] % ml[sm]) continue;
      for (int j = 0; j < n; ++j)
        if ((sm >> j) & 1) v[j] = 2, num += p3[j];
      v[i] = 1;
      num += p3[i];
      ret = min(ret, cnt[1 << i] - cnt[sm] + (cnt[1 << i] != 1) +
                         solve(num, (m ^ sm) | (1 << i)));
      num -= p3[i];
      v[i] = 0;
      for (int j = 0; j < n; ++j)
        if ((sm >> j) & 1) v[j] = 1, num -= p3[j];
    }
  }
  return ret;
}
int main() {
  p3[0] = 1;
  for (int i = 1; i < 8; i++) p3[i] = 3 * p3[i - 1];
  for (int i = 1, j = 0; i < (1 << 8); i <<= 1, j++) lg[i] = j;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%lld", &arr[i]);
  sort(arr, arr + n);
  n = unique(arr, arr + n) - arr;
  for (int i = 0; i < n; ++i) {
    long long v = arr[i];
    for (long long j = 2; j * j <= v; j++)
      while (v % j == 0) v /= j, ++cnt[1 << i];
    if (v > 1) ++cnt[1 << i];
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    ml[mask] = 1;
    if (mask) ml[mask] = mul(ml[mask ^ (mask & -mask)], arr[lg[mask & -mask]]);
    if (mask) cnt[mask] = cnt[mask ^ (mask & -mask)] + cnt[mask & -mask];
  }
  memset(memo, -1, sizeof memo);
  cout << solve(0, 0) << endl;
}
