#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
vector<pair<int, int>> List[N];
int depth[N];
int n;
long long ans;
int Cnt[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<int> primes;
  for (int i = 2; i <= 5000; i++) {
    int cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 2) primes.push_back(i);
  }
  for (int i = 2; i <= 5000; i++) {
    for (int p : primes) {
      int mul = p;
      int c = 0;
      while (mul <= i) {
        c += i / mul;
        mul *= p;
      }
      depth[i] += c;
      if (c) List[i].push_back({p, c});
    }
  }
  cin >> n;
  vector<int> f(5001);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    f[x]++;
    ans += depth[x];
  }
  vector<pair<int, int>> sub;
  for (int i = 2; i <= 5000; i++) {
    if (f[i]) sub.push_back({i, f[i]});
  }
  while (true) {
    int heavy_child = -1, sz = 0;
    for (int i = 0; i < sub.size(); i++) {
      int x = sub[i].first, c = sub[i].second;
      int p = List[x].back().first;
      Cnt[p] += c;
      if (Cnt[p] > sz) {
        sz = Cnt[p];
        heavy_child = p;
      }
    }
    if (sz <= n / 2) break;
    int other = n - sz;
    ans += -sz + other;
    vector<pair<int, int>> new_sub;
    for (int i = 0; i < sub.size(); i++) {
      int x = sub[i].first, c = sub[i].second;
      int p = List[x].back().first;
      Cnt[p] -= c;
      if (p == heavy_child) {
        List[x].back().second--;
        if (List[x].back().second == 0) List[x].pop_back();
        if (!List[x].empty()) new_sub.push_back(sub[i]);
      }
    }
    sub = new_sub;
  }
  cout << ans << endl;
  return 0;
}
