#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
const int M = 1e6;
int n, k[M + 10], cnt[N + 10];
int center[N + 10];
int count_fac[N + 10][N + 10];
int vis[N + 10];
void init() {
  for (int i = 2; i <= N; i++) {
    for (int j = 1; j <= i; j++) count_fac[i][j] = count_fac[i - 1][j];
    int pre = i;
    for (int j = 2; j <= (int)sqrt(pre); j++) {
      while (pre % j == 0) {
        count_fac[i][j]++;
        pre /= j;
      }
    }
    if (pre > 1) count_fac[i][pre]++;
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &k[i]);
    cnt[k[i]]++;
  }
  init();
  long long mi, siz = 0;
  for (int i = 1; i <= N; i++) {
    if (!cnt[i]) continue;
    center[i] = 1;
    for (int j = 1; j <= i; j++) {
      siz += 1LL * count_fac[i][j] * cnt[i];
      if (count_fac[i][j]) center[i] = j;
    }
  }
  mi = siz;
  while (true) {
    vector<long long> v(N + 10, 0);
    for (int i = 1; i <= N; i++) {
      if (!cnt[i]) continue;
      v[center[i]] += cnt[i];
    }
    int pos = max_element(v.begin() + 1, v.end()) - v.begin();
    int val = v[pos];
    if (val * 2 <= n || pos == 1) break;
    siz -= 2 * val - n;
    mi = min(mi, siz);
    for (int i = 1; i <= N; i++) {
      if (!cnt[i]) continue;
      if (center[i] != pos) center[i] = 0;
      if (center[i]) count_fac[i][center[i]]--;
      while (count_fac[i][center[i]] == 0 && center[i] > 0) center[i]--;
    }
  }
  printf("%lld\n", mi);
}
