#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
bool simple[N];
vector<pair<int, int> > D[5005];
int all[5005];
void precalc() {
  for (int i = 0; i < N; i++) {
    simple[i] = 1;
  }
  simple[0] = 0, simple[1] = 1;
  for (int i = 2; i < N; i++) {
    if (!simple[i]) continue;
    vector<int> coun(N);
    for (int j = i; j < N; j += i) {
      simple[j] = 0;
      int x = j;
      while (x % i == 0) {
        coun[j]++;
        x /= i;
      }
    }
    simple[i] = 1;
    for (int j = 1; j < N; j++) {
      coun[j] += coun[j - 1];
      all[j] += coun[j];
      if (coun[j] > 0) D[j].push_back({i, coun[j]});
    }
  }
}
vector<int> numb[N];
int S[N];
int cnt[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int n;
  cin >> n;
  vector<int> arr(n);
  vector<int> alive;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cnt[arr[i]] += 1;
    if (arr[i] > 1 && cnt[arr[i]] == 1) alive.push_back(arr[i]);
    ans += all[arr[i]];
  }
  while (1) {
    for (int i = 0; i < N; i++) {
      numb[i].clear();
      S[i] = 0;
    }
    for (int ind : alive) {
      int len = D[ind].size();
      int d = D[ind][len - 1].first;
      numb[d].push_back(ind);
      S[d] += cnt[ind];
    }
    int d = -1;
    for (int i = 0; i < N; i++) {
      if (S[i] * 2 > n) {
        d = i;
        break;
      }
    }
    if (d == -1) break;
    int sz = S[d];
    ans -= (2 * sz - n);
    alive.clear();
    for (int ind : numb[d]) {
      int len = D[ind].size();
      D[ind][len - 1].second--;
      if (D[ind][len - 1].second == 0) D[ind].pop_back();
      if (D[ind].size() > 0) {
        alive.push_back(ind);
      }
    }
  }
  cout << ans << endl;
}
