#include <bits/stdc++.h>
using namespace std;
int n, x, m;
long long ans;
int s[5005], h[5005], deep[5005], t[5005], dist[5005][5005], flag[5005];
int getlca(int a, int b) { return (deep[a] + deep[b] - dist[a][b]) / 2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    m = max(m, x);
    s[x]++;
  }
  for (int i = 2; i <= m; i++) {
    deep[i] = deep[i - 1];
    int mx = 0, tmp = i;
    for (int j = 2; j * j <= tmp; j++) {
      if (tmp % j == 0) mx = max(mx, j);
      while (tmp % j == 0) tmp = tmp / j;
    }
    if (tmp != 1) mx = max(mx, tmp);
    for (int j = m; j >= mx; j--) h[i - 1] += t[j];
    tmp = i;
    for (int j = 2; j * j <= tmp; j++)
      while (tmp % j == 0) tmp = tmp / j, t[j]++, deep[i]++;
    if (tmp != 1) t[tmp]++, deep[i]++;
  }
  for (int i = 0; i <= m; i++) {
    dist[i][i] = 0;
    int tk = 1e9;
    for (int j = i - 1; j >= 0; j--) {
      tk = min(tk, h[j]);
      dist[i][j] = dist[j][i] = deep[i] + deep[j] - 2 * tk;
    }
  }
  ans = 1e17;
  for (int i = 0; i <= m; i++) {
    long long sum = 0;
    for (int j = 0; j <= m; j++) sum += (long long)dist[i][j] * s[j];
    ans = min(ans, sum);
  }
  if (m <= 100) {
    for (int i = 0; i <= m; i++) {
      for (int j = 0; j <= m; j++) {
        int ti = getlca(i, j);
        if (flag[ti] == i + 1) continue;
        flag[ti] = i + 1;
        long long sum = 0;
        for (int k = 0; k <= m; k++) {
          int tmp = dist[i][k], tk = getlca(i, k);
          tmp = tmp - deep[i] + tk + abs(ti - tk);
          sum += (long long)tmp * s[k];
        }
        ans = min(ans, sum);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
