#include <bits/stdc++.h>
using namespace std;
int prime[5001][5001];
int maxP[10001];
int cnt[10001];
int cntMaxP[10001];
int freq[10001];
void init() {
  memset(prime, 0, sizeof(prime));
  maxP[1] = 1;
  prime[1][1] = 1;
  for (int i = 2; i <= 5000; ++i) {
    for (int j = 1; j <= 5000; ++j) prime[i][j] = prime[i - 1][j];
    maxP[i] = maxP[i - 1];
    int len = sqrt(i);
    int s = i;
    for (int j = 2; j <= len; ++j)
      while (s % j == 0) {
        prime[i][j]++;
        maxP[i] = max(maxP[i], j);
        s /= j;
      }
    if (s > 1) {
      prime[i][s]++;
      maxP[i] = max(maxP[i], s);
    }
  }
}
int main() {
  init();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    cnt[k]++;
  }
  int maxk = 5000;
  long long cur = 0;
  for (int i = 0; i <= 5000; ++i) {
    if (!cnt[i]) {
      maxP[i] = 1;
      continue;
    }
    for (int j = 2; j <= 5000; ++j) {
      cur += 1LL * cnt[i] * prime[i][j];
    }
  }
  int now = 1;
  while (*max_element(maxP, maxP + 5000 + 1) > 1) {
    for (int i = 0; i <= 5000; ++i) freq[i] = 0;
    for (int i = 0; i <= 5000; ++i) freq[maxP[i]] += cnt[i];
    int selected = max_element(freq + 1, freq + 5001) - freq;
    if (selected == 1) break;
    if (freq[selected] * 2 < n) break;
    cur = cur + n - 2 * freq[selected];
    for (int i = 1; i <= 5000; ++i) {
      if (maxP[i] == 1) continue;
      if (maxP[i] != selected)
        maxP[i] = 1;
      else {
        prime[i][maxP[i]]--;
        while (maxP[i] > 1 && !prime[i][maxP[i]]) maxP[i]--;
      }
    }
  }
  printf("%lld", cur);
}
