#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int M = 5e3 + 10;
const int mod = 1e9 + 7;
int cnt[M][M];
void init() {
  for (int i = 1; i < M; i++) {
    int p = i;
    for (int j = 1; j <= i; j++) cnt[i][j] = cnt[i - 1][j];
    for (int j = 2; j <= p; j++) {
      if (p % j == 0) {
        while (p % j == 0) p /= j, cnt[i][j]++;
      }
    }
  }
}
int n, f[M], v[M], siz[M];
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    v[x]++;
  }
  long long ans = 0;
  for (int i = 1; i < M; i++)
    for (int j = 1; j <= i; j++)
      if (cnt[i][j]) f[i] = j, ans += 1ll * v[i] * cnt[i][j];
  while (1) {
    memset(siz, 0, sizeof(siz));
    for (int i = 1; i < M; i++) siz[f[i]] += v[i];
    int mx = 0, pl = 1;
    for (int i = 1; i < M; i++)
      if (siz[i] > mx) {
        mx = siz[i];
        pl = i;
      }
    if (pl == 1) break;
    if (2 * mx <= n) break;
    ans = ans + n - 2 * mx;
    for (int i = 1; i < M; i++) {
      if (f[i] != pl)
        f[i] = 1;
      else {
        cnt[i][f[i]]--;
        while (!cnt[i][f[i]] && f[i] > 1) f[i]--;
      }
    }
  }
  printf("%lld", ans);
}
