#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 5005, P = 1000;
int w[N], pr[N], z[N][P], taken[N], bad[N];
int cp = 0, n, x;
int get_size() {
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (bad[i]) continue;
    bool ok = true;
    for (int j = x + 1; j < cp; j++) {
      if (taken[j] != z[i][j]) {
        ok = false;
      }
    }
    if (!ok) {
      bad[i] = true;
    }
    if (ok && z[i][x] >= taken[x]) {
      ans += w[i];
    }
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  for (int i = 2; i < N; i++) {
    bool prime = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        prime = false;
        break;
      }
    }
    if (prime) {
      pr[cp++] = i;
    }
  }
  for (int i = 1; i < N; i++) {
    int x = i;
    for (int j = 0; j < cp; j++) {
      while (x % pr[j] == 0) {
        x /= pr[j];
        z[i][j]++;
      }
      z[i][j] += z[i - 1][j];
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    w[k]++;
  }
  long long ans = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < cp; j++) {
      ans += z[i][j] * (long long)w[i];
    }
  }
  x = cp - 1;
  while (true) {
    taken[x]++;
    int sz1 = get_size();
    if (n - sz1 < sz1) {
      ans -= sz1 - n + sz1;
      continue;
    }
    taken[x]--;
    x--;
    int sz2 = get_size();
    if (n - sz2 < sz2) {
      continue;
    }
    break;
  }
  cout << ans;
  return 0;
}
