#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
const int maxm = 5e5 + 10;
int cnt[maxn];
map<int, int> fac;
void factor(int x) {
  int sx = sqrt(x);
  for (int i = 2; i <= sx; i++) {
    while (x % i == 0) {
      fac[i]++;
      x /= i;
    }
  }
  if (x != 1) fac[x]++;
}
map<int, int> T[maxm];
int tot, multi[maxm], mark[maxm];
void insert(int u, map<int, int>::reverse_iterator it, int k) {
  if (it == fac.rend()) {
    mark[u] = k;
    return;
  }
  int x = it->first, c = it->second;
  while (T[u].count(x)) {
    u = T[u][x];
    c -= multi[u];
  }
  if (c) {
    int v = ++tot;
    T[u][x] = v;
    multi[v] = c;
    insert(v, ++it, k);
  } else {
    insert(u, ++it, k);
  }
}
void build() {
  tot = 1;
  multi[1] = 1;
  mark[1] = cnt[1];
  for (int i = 2; i <= 5000; i++) {
    factor(i);
    insert(1, fac.rbegin(), cnt[i]);
  }
}
long long ans = 0;
long long sub[maxm], dp[maxm];
void init_dfs(int x, long long dep) {
  ans += 1LL * dep * mark[x];
  sub[x] = mark[x];
  for (auto y : T[x]) {
    init_dfs(y.second, dep + multi[y.second]);
    sub[x] += sub[y.second];
  }
}
int n;
void dp_dfs(int x) {
  ans = min(ans, dp[x]);
  for (auto y : T[x]) {
    dp[y.second] = dp[x] - multi[y.second] * sub[y.second] +
                   multi[y.second] * (n - sub[y.second]);
    dp_dfs(y.second);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 0)
      cnt[1]++;
    else
      cnt[x]++;
  }
  build();
  init_dfs(1, 0);
  dp[1] = ans;
  dp_dfs(1);
  cout << ans << endl;
}
