#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
long long a[N], p[N][N];
int b[N], cnt[N], fre[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int temp;
    scanf("%d", &temp);
    a[max(1, temp)]++;
  }
  for (int i = 2; i < N; i++) {
    int temp = i;
    for (int j = 2; j < N; j++) {
      while (temp % j == 0) {
        temp /= j;
        p[i][j]++;
      }
      p[i][j] += p[i - 1][j];
    }
  }
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    if (a[i] == 0) {
      b[i] = 1;
      continue;
    }
    for (int j = 2; j < N; j++) {
      ans += a[i] * p[i][j];
      if (p[i][j]) b[i] = j;
    }
  }
  while (*max_element(b + 1, b + N) > 1) {
    memset(fre, 0, sizeof(fre));
    for (int i = 1; i < N; i++) {
      fre[b[i]] += a[i];
    }
    int mx = max_element(fre + 1, fre + N) - fre;
    int t = *max_element(fre + 1, fre + N);
    if (mx == 1 || t <= n / 2) break;
    ans += n - 2 * t;
    for (int i = 2; i < N; i++) {
      if (b[i] != mx) {
        b[i] = 1;
      } else if (b[i] == mx) {
        p[i][b[i]]--;
        while (p[i][b[i]] == 0 && b[i] > 1) {
          b[i]--;
        }
      }
    }
  }
  printf("%lld", ans);
}
