#include <bits/stdc++.h>
using namespace std;
const int K = 5000;
int n, num[K + 3], divp[K + 3][K + 3], ed[K + 3];
long long ans;
int main() {
  scanf("%d", &n);
  for (int i = 1, k; i <= n; i++) scanf("%d", &k), num[k]++;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) divp[i][j] += divp[i - 1][j];
    int now = i;
    for (int x = 2; x * x <= now; x++) {
      while (now % x == 0) {
        divp[i][x]++;
        now /= x;
      }
    }
    if (now > 1) divp[i][now]++;
  }
  for (int i = 1; i <= K; i++) {
    if (num[i] == 0) {
      ed[i] = 1;
      continue;
    }
    for (int j = 1; j <= K; j++) {
      ans += (long long)divp[i][j] * num[i];
      if (divp[i][j]) ed[i] = j;
    }
  }
  long long now = ans;
  while (*max_element(ed + 1, ed + 1 + K) > 1) {
    vector<int> cnt(K + 3, 0);
    for (int i = 1; i <= K; i++) cnt[ed[i]] += num[i];
    int p = max_element(cnt.begin(), cnt.end()) - cnt.begin(), sz = cnt[p];
    if (sz * 2 <= n || p == 1) break;
    now = ans - 2 * sz + n;
    ans = min(ans, now);
    for (int i = 1; i <= K; i++) {
      if (ed[i] != p) ed[i] = 1;
      if (ed[i] == 1) continue;
      divp[i][ed[i]]--;
      while (ed[i] > 1 && divp[i][ed[i]] == 0) ed[i]--;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
