#include <bits/stdc++.h>
using namespace std;
int n, maxX, cnt[5005], f[5005][5005];
int notP[5005];
void prepare() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
    maxX = max(maxX, x);
  }
  vector<int> primes;
  notP[0] = notP[1] = 1;
  for (int i = 2; i <= maxX; i++)
    if (!notP[i]) {
      primes.push_back(i);
      for (int j = 2 * i; j <= maxX; j += i) notP[j] = 1;
    }
  for (int val = 2; val <= maxX; val++) {
    for (auto x : primes) {
      for (int y = x; y <= val; y *= x) f[val][x] += val / y;
    }
  }
}
int curPrime[5005], freq[5005];
void solve() {
  long long res = 0, curAns = 0;
  for (int i = 1; i <= maxX; i++) {
    curPrime[i] = 1;
    if (!cnt[i]) continue;
    for (int j = 1; j <= maxX; j++) {
      res += 1ll * f[i][j] * cnt[i];
      curAns += 1ll * f[i][j] * cnt[i];
      if (f[i][j]) curPrime[i] = j;
    }
  }
  while (1) {
    for (int i = 1; i <= maxX; i++) freq[i] = 0;
    for (int i = 1; i <= maxX; i++) freq[curPrime[i]] += cnt[i];
    int nextPrime = 1;
    for (int i = 2; i <= maxX; i++)
      if (freq[i] * 2 > n) nextPrime = i;
    if (nextPrime == 1) break;
    curAns += n - freq[nextPrime] * 2;
    res = min(res, curAns);
    for (int i = 1; i <= maxX; i++) {
      if (curPrime[i] != nextPrime) curPrime[i] = 1;
      if (curPrime[i] == 1) continue;
      f[i][curPrime[i]]--;
      while (curPrime[i] > 1 && f[i][curPrime[i]] == 0) curPrime[i]--;
    }
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("INP.TXT", "r")) {
    freopen("INP.TXT", "r", stdin);
  }
  prepare();
  solve();
}
