#include <bits/stdc++.h>
using namespace std;
int n, k = 5000;
int d[5005];
int cnt[5005];
vector<int> pr;
int id[5005];
int fac[5005][1005];
int s[5005][1005];
void sieve(void) {
  for (int i = 2; i <= k; ++i)
    if (!d[i]) {
      id[i] = pr.size();
      pr.push_back(i);
      for (int j = i; j <= k; j += i)
        if (!d[j]) d[j] = i;
    }
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < pr.size(); ++j) fac[i][j] = fac[i - 1][j];
    int tmp = i;
    while (tmp > 1) {
      int t = d[tmp];
      ++fac[i][id[t]];
      tmp /= t;
    }
    for (int j = 0; j < pr.size(); ++j) s[i][j] = fac[i][j] + s[i][j - 1];
  }
}
int f[1005];
long long solve(void) {
  long long ans = 0;
  int rem = 0;
  for (int i = 0; i < pr.size(); ++i) rem += f[i];
  vector<int> cand(k, 0);
  iota(cand.begin(), cand.end(), 1);
  int l = 1, r = k;
  for (int i = pr.size() - 1; i >= 0; --i) {
    rem -= f[i];
    while (l <= r && fac[l][i] < f[i]) {
      ans +=
          1ll * cnt[l] * (rem + (i ? s[l][i - 1] : 0) + abs(fac[l][i] - f[i]));
      ++l;
    }
    while (r >= l && fac[r][i] > f[i]) {
      ans +=
          1ll * cnt[r] * (rem + (i ? s[r][i - 1] : 0) + abs(fac[r][i] - f[i]));
      --r;
    }
  }
  return ans;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  int x;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    if (x == 0) x = 1;
    ++cnt[x];
  }
  sieve();
  long long ans = 1e18;
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < pr.size(); ++j) f[j] = fac[i][j];
    ans = min(ans, solve());
  }
  for (int i = 1; i < k; ++i) {
    int flg = 0;
    for (int j = pr.size() - 1; j >= 0; --j) {
      if (flg)
        f[j] = 0;
      else if (fac[i][j] != fac[i + 1][j]) {
        flg = 1;
        f[j] = min(fac[i][j], fac[i + 1][j]);
      } else
        f[j] = fac[i][j];
    }
    ans = min(ans, solve());
  }
  cout << ans << endl;
  return 0;
}
