#include <bits/stdc++.h>
using namespace std;
const long long MaxN = 5e3 + 10;
const long long LogN = 20;
const long long md = 1e9 + 7;
const long long Inf = 1e9;
bool used[MaxN];
long long Cnt[MaxN];
long long Cnt_PD[MaxN][MaxN];
long long t[MaxN];
long long Vt[MaxN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  for (int i = 2; i < MaxN; i++) {
    if (used[i] == 0) {
      used[i] = 1;
      for (int j = i; j < MaxN; j += i) {
        long long t = j;
        while (t % i == 0) Cnt_PD[j][i]++, t /= i;
        used[j] = 1;
      }
    }
  }
  for (int i = 2; i < MaxN; i++) {
    for (int j = 0; j < MaxN; j++) {
      Cnt_PD[i][j] += Cnt_PD[i - 1][j];
    }
  }
  long long Ans = 0;
  long long Now = 0;
  long long N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    if (a == 0) continue;
    Cnt[a]++;
  }
  memset(used, 0, sizeof(used));
  for (int i = 0; i < MaxN; i++) {
    for (int j = 0; j < MaxN; j++) {
      if (Cnt_PD[i][j] && Cnt[i]) t[i] = j;
      Ans += Cnt_PD[i][j] * Cnt[i];
    }
  }
  Now = Ans;
  while (*max_element(t, t + MaxN) > 1) {
    memset(Vt, 0, sizeof(Vt));
    for (int i = 0; i < MaxN; i++) Vt[t[i]] += Cnt[i];
    int id = max_element(Vt, Vt + MaxN) - Vt;
    int div = Vt[id];
    if (div * 2 <= N) break;
    if (id == 1) break;
    Now -= div, Now += (N - div), Ans = min(Ans, Now);
    for (int i = 0; i < MaxN; i++) {
      if (t[i] != id) {
        t[i] = 1;
        continue;
      }
      Cnt_PD[i][t[i]]--;
      while (t[i] > 1 && Cnt_PD[i][t[i]] == 0) t[i]--;
    }
  }
  cout << Ans << '\n';
  return 0;
}
