#include <bits/stdc++.h>
using namespace std;
inline void fileio(const char* in, const char* out) {
  freopen(in, "r", stdin);
  freopen(out, "w", stdout);
}
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<ll> VL;
const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const ld EPS = 1e-9, PI = acos(-1);
using ms = map<int, ll, greater<int>>;
struct mulset {
  const ll cnt;
  ms data;
  ll sz;
  mulset(ms& init, int c) : cnt(c) {
    data.swap(init);
    sz = 0;
    for (auto e : data) {
      sz += e.second;
    }
  }
  void pop() {
    assert(sz > 0);
    sz--;
    auto it = data.begin();
    it->second -= 1;
    if (it->second == 0) {
      data.erase(it);
    }
  }
  int front() { return data.begin()->first; }
};
const int K = 5005;
ms fact[K];
void pre() {
  for (int k = 2; k < K; k++) {
    int i = k;
    fact[k] = fact[k - 1];
    for (int f = 2; i > 1; ++f) {
      while (i % f == 0) {
        fact[k][f] = fact[k][f] + 1;
        i /= f;
      }
    }
  }
}
int main() {
  atexit([]() { cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  pre();
  int n;
  cin >> n;
  VI cnt(K);
  for (int i = 0; i < (n); ++i) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  ll ans = 0;
  list<mulset> nums;
  for (int k = 0; k < (K); ++k) {
    if (cnt[k] && fact[k].size() > 0) {
      nums.emplace_back(fact[k], cnt[k]);
      ans += nums.back().sz * cnt[k];
    }
  }
  while (1) {
    pair<int, ll> best = {-1, 0};
    for (auto& e : nums) {
      pair<int, ll> cur = {e.front(), e.cnt};
      if (cur.first == best.first) {
        best.second += cur.second;
      } else if (cur.second > best.second) {
        best = {cur.first, cur.second - best.second};
      } else {
        best.second -= cur.second;
      }
    }
    best.second = 0;
    for (auto& e : nums) {
      if (e.front() == best.first) {
        best.second += e.cnt;
      }
    }
    if (best.second > n / 2) {
      ans -= best.second;
      ans += (n - best.second);
      for (auto it = nums.begin(); it != nums.end();) {
        auto nx = next(it);
        if (it->front() == best.first) {
          it->pop();
          if (it->sz == 0) {
            nums.erase(it);
          }
        } else {
          nums.erase(it);
        }
        it = nx;
      }
    } else
      break;
  }
  cout << ans << nl;
  return 0;
}
