#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::pair;
using std::string;
using std::vector;
using vi = vector<int>;
using pii = pair<int, int>;
using vii = vector<pii>;
using ll = long long;
int solve();
int main(int argc, char* argv[]) {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  ::std::cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; ++i) {
    solve();
  }
}
constexpr int N = 5030;
int n;
int cnt[N];
int dp[N], fq[N];
vi pe[N];
int solve() {
  for (int i = 0; i < N; ++i) {
    pe[i].resize(N);
  }
  for (int i = 2; i < N; ++i) {
    for (int j = 0; j < N; ++j) pe[i][j] += pe[i - 1][j];
    int t = i;
    for (int x = 2, tq = sqrt(t); x <= tq; ++x) {
      while (t % x == 0) {
        pe[i][x]++;
        t /= x;
      }
    }
    if (t > 1) pe[i][t]++;
  }
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    cnt[k]++;
  }
  for (int i = 0; i < N; ++i) {
    dp[i] = 1;
  }
  ll ans = 0, cur = 0;
  for (int i = 1; i < N; ++i) {
    if (!cnt[i]) {
      dp[i] = 1;
      continue;
    }
    int sum = 0;
    for (int j = 1; j < N; ++j) {
      sum += pe[i][j];
      if (pe[i][j]) dp[i] = j;
    }
    ans += sum * 1LL * cnt[i];
    cur += sum * 1LL * cnt[i];
  }
  while (*::std::max_element(dp, dp + N) > 1) {
    memset(fq, 0, sizeof(fq));
    for (int i = 0; i < N; ++i) fq[dp[i]] += cnt[i];
    int bp = std::max_element(fq, fq + N) - fq;
    int bg = fq[bp];
    if (bg * 2 <= n || bp == 1) break;
    cur -= bg;
    cur += (n - bg);
    ans = std::min(ans, cur);
    for (int i = 0; i < N; ++i) {
      if (dp[i] != bp) dp[i] = 1;
      if (dp[i] == 1) continue;
      pe[i][dp[i]] -= 1;
      while (dp[i] > 1 && pe[i][dp[i]] == 0) --dp[i];
    }
  }
  cout << ans << endl;
  return 0;
}
