#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
vector<pair<int, int>> fac[N];
int dis[N], fr[N];
int top(int u) {
  if (fac[u].empty()) return -1;
  int ans = fac[u].back().first;
  fac[u].back().second--;
  if (fac[u].back().second == 0) fac[u].pop_back();
  return ans;
}
int vv[N], cnt[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  map<int, int> mp;
  for (int i = 1; i < N; i++) {
    int x = i, add = 0;
    for (int d = 2; d <= i; d++) {
      int cnt = 0;
      while (x % d == 0) cnt++, x /= d;
      if (cnt) mp[d] += cnt;
      add += cnt;
    }
    dis[i] = dis[i - 1] + add;
    fac[i].assign(mp.begin(), mp.end());
  }
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    fr[x]++;
    ans += dis[x];
  }
  vector<int> v(N);
  iota(v.begin(), v.end(), 0);
  while (true) {
    memset(cnt, 0, sizeof cnt);
    for (int x : v) {
      int u = top(x);
      if (u == -1) continue;
      vv[x] = u;
      cnt[u] += fr[x];
    }
    int mxid = 0;
    for (int i = 0; i < N; i++) {
      if (cnt[mxid] < cnt[i]) mxid = i;
    }
    if (cnt[mxid] * 2 <= n)
      break;
    else {
      ans = ans + n - cnt[mxid] - cnt[mxid];
      vector<int> nw;
      for (int x : v)
        if (vv[x] == mxid) nw.push_back(x);
      v = nw;
    }
  }
  cout << ans << endl;
}
