#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
int n, maxf[N];
long long fac[N][N], num[N], sum[N];
void init() {
  for (int i = 2; i < N; i++) {
    for (int j = 2; j < N; j++) fac[i][j] += fac[i - 1][j];
    int x = i;
    for (int j = 2; j * j <= x; j++) {
      while (x % j == 0) {
        fac[i][j]++, x /= j;
      }
    }
    if (x > 1) fac[i][x]++;
  }
}
void solve() {
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    maxf[i] = 1;
    if (!num[i]) continue;
    for (int j = 1; j < N; j++) {
      if (!fac[i][j]) continue;
      ans += fac[i][j] * num[i], maxf[i] = j;
    }
  }
  while (1) {
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i < N; i++) sum[maxf[i]] += num[i];
    int idx = max_element(sum, sum + N) - sum;
    if (idx == 1) break;
    int id = sum[idx];
    if (n - id >= id) break;
    ans += n - id * 2;
    for (int i = 1; i < N; i++) {
      if (maxf[i] != idx) maxf[i] = 1;
      if (maxf[i] == 1) continue;
      fac[i][idx]--;
      while (fac[i][maxf[i]] == 0 && maxf[i] != 1) maxf[i]--;
    }
  }
  cout << ans << endl;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x), num[x]++;
  }
  solve();
}
