#include <bits/stdc++.h>
using namespace std;
void Freopen() {
  freopen(
      "CF1292D Chaotic V."
      ".in",
      "r", stdin);
  freopen(
      "CF1292D Chaotic V."
      ".out",
      "w", stdout);
}
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int N = 5e3 + 5;
const int maxn = 5e3;
int n, nu[N], f[N][N], p[N], s[N];
long long ans, now;
signed main() {
  n = read();
  for (int i = (1); i <= (n); i++) {
    int x = read();
    nu[x]++;
  }
  for (int i = (2); i <= (maxn); i++) {
    memcpy(f[i], f[i - 1], sizeof(f[i]));
    int x = i;
    for (int j = (2); j <= (x); j++)
      while (x % j == 0) f[i][j]++, x /= j;
  }
  for (int i = (1); i <= (maxn); i++) {
    if (!nu[i])
      p[i] = 1;
    else
      for (int j = (1); j <= (i); j++)
        if (f[i][j]) p[i] = j, now += 1ll * f[i][j] * nu[i];
  }
  ans = now;
  while (*max_element(p + 1, p + maxn + 1) > 1) {
    memset(s, 0, sizeof(s));
    for (int i = (0); i <= (maxn); i++) s[p[i]] += nu[i];
    int x = max_element(s + 1, s + maxn + 1) - s, w = s[x];
    if (w * 2 <= n || x == 1) break;
    ans = min(ans, now -= w * 2 - n);
    for (int i = (0); i <= (maxn); i++) {
      if (p[i] != x) p[i] = 1;
      if (p[i] == 1) continue;
      f[i][p[i]]--;
      while (p[i] > 1 && !f[i][p[i]]) p[i]--;
    }
  }
  cout << ans;
  return signed();
}
