#include <bits/stdc++.h>
using std::cin;
using std::cout;
int n;
int prime[5000 + 1], frag[5000 + 1], cntprime, id[5000 + 1];
std::vector<int> facts[5000 + 1];
long long instdist, ans;
void in() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    ++frag[(k == 0) ? 1 : k];
  }
}
void cprimes() {
  prime[0] = prime[1] = 1;
  int cnt = 0;
  for (int i = 2; i < 5000; ++i)
    if (prime[i] == 0) {
      prime[i] = i;
      id[i] = cnt++;
      for (int j = i * i; j <= 5000; j += i)
        if (!prime[j]) prime[j] = i;
    }
}
int cntfact(int x) {
  int cnt = 0;
  facts[x] = facts[x - 1];
  if (prime[x] != 1 && id[prime[x]] >= facts[x].size()) facts[x].push_back(0);
  for (int tmp = x; tmp > 1; tmp /= prime[tmp]) {
    ++facts[x][id[prime[tmp]]];
    ++cnt;
  }
  return cnt;
}
void pp() {
  cprimes();
  int cr = 0;
  instdist = 0;
  for (int i = 1; i <= 5000; ++i) {
    cr += cntfact(i);
    instdist += (long long)cr * frag[i];
  }
}
void prs() {
  int l = 2, r = 5000 + 1;
  ans = instdist;
  while (l < r) {
    int most = 0, num = frag[l], lmost = l, rmost = l + 1, cr = l + 1, cl = l;
    for (int i = l + 1; i < r; ++i) {
      if (facts[i].size() != facts[i - 1].size()) {
        if (num > most) {
          most = num;
          lmost = cl;
          rmost = cr;
        }
        num = 0;
        cl = i;
      }
      num += frag[i];
      ++cr;
    }
    if (num > most) {
      most = num;
      lmost = cl;
      rmost = cr;
    }
    if (most <= n >> 1) break;
    ans += n - (most << 1);
    for (int i = lmost; i < rmost; ++i) {
      --facts[i].back();
      if (facts[i].back() == 0) facts[i].pop_back();
    }
    l = lmost;
    r = rmost;
    for (; facts[l].empty(); ++l)
      if (l == r) break;
  }
}
void out() { cout << ans; }
void run() {
  in();
  pp();
  prs();
  out();
}
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  run();
  return 0;
}
