#include <bits/stdc++.h>
using namespace std;
int f[5001][5001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  for (int i = 2; i < 5001; ++i) {
    for (int j = 2; j < 5001; ++j) {
      f[i][j] = f[i - 1][j];
    }
    int val = i;
    for (int x = 2; x * x <= val; ++x) {
      while (val % x == 0) {
        ++f[i][x];
        val /= x;
      }
    }
    if (val > 1) {
      ++f[i][val];
    }
  }
  int n;
  cin >> n;
  vector<int> cnt(5001);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    ++cnt[k];
  }
  int64_t ans = 0;
  for (int i = 2; i < 5001; ++i) {
    for (int j = 2; j < 5001; ++j) {
      ans += 1LL * cnt[i] * f[i][j];
    }
  }
  vector<int> rem;
  for (int i = 0; i < 5001; ++i) {
    rem.push_back(i);
  }
  vector<int> bound(5001, 5000);
  while (true) {
    vector<int> cur_max(5001);
    for (int x : rem) {
      for (int i = bound[x]; i >= 2; --i) {
        bound[x] = i;
        if (f[x][i] > 0) {
          cur_max[i] += cnt[x];
          break;
        }
      }
    }
    int pd = max_element(cur_max.begin(), cur_max.end()) - cur_max.begin();
    if (cur_max[pd] > n - cur_max[pd]) {
      ans -= cur_max[pd];
      ans += n - cur_max[pd];
      vector<int> n_rem;
      for (int x : rem) {
        if (f[x][pd] > 0) {
          --f[x][pd];
          n_rem.push_back(x);
        }
      }
      rem = n_rem;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
