#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
long long p_cnt[N][N];
long long largest_prime[N];
int n;
long long cnt[N];
int lp_cnt[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i <= 5000; i++) {
    for (int j = 1; j <= i; j++) {
      p_cnt[i][j] += p_cnt[i - 1][j];
    }
    int x = i;
    for (int j = 2; j <= x; j++) {
      while (x % j == 0) p_cnt[i][j]++, x /= j;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= 5000; i++) {
    if (!cnt[i]) {
      largest_prime[i] = 1;
      continue;
    }
    for (int j = 1; j <= 5000; j++) {
      ans += cnt[i] * p_cnt[i][j];
      if (p_cnt[i][j]) largest_prime[i] = j;
    }
  }
  while (1) {
    long long o = 0;
    for (int i = 1; i <= 5000; i++) {
      o = max(o, largest_prime[i]);
    }
    if (o <= 1) break;
    memset(lp_cnt, 0, sizeof lp_cnt);
    for (int i = 1; i <= 5000; i++) {
      lp_cnt[largest_prime[i]] += cnt[i];
    }
    long long most_frequent_largest_prime = 0, max_vaule_of_lp_cnt = -1;
    for (int i = 1; i <= 5000; i++) {
      if (lp_cnt[i] > max_vaule_of_lp_cnt) {
        max_vaule_of_lp_cnt = lp_cnt[i];
        most_frequent_largest_prime = i;
      }
    }
    if (max_vaule_of_lp_cnt * 2 <= n || most_frequent_largest_prime == 1) break;
    ans -= max_vaule_of_lp_cnt;
    ans += n - max_vaule_of_lp_cnt;
    for (int i = 1; i <= 5000; i++) {
      if (largest_prime[i] != most_frequent_largest_prime) largest_prime[i] = 1;
      if (largest_prime[i] == 1) continue;
      p_cnt[i][most_frequent_largest_prime]--;
      while (largest_prime[i] > 1 && p_cnt[i][largest_prime[i]] == 0)
        largest_prime[i]--;
    }
  }
  cout << ans << endl;
  return 0;
}
