#include <bits/stdc++.h>
using namespace std;
bool isPrime[5001];
void primess(int n, map<int, int> &s) {
  for (int i = 2; i <= n; ++i)
    if (isPrime[i]) {
      while (n % i == 0) {
        s[i]++;
        n /= i;
      }
    }
}
int n;
vector<vector<pair<pair<int, int>, int>>> v;
int w[5001];
vector<long long> s;
vector<long long> dep;
long long res = 0;
int cur = 0;
void dfs(int u) {
  for (auto a : v[u]) {
    dfs(a.second);
    s[u] += s[a.second];
  }
}
bool improve() {
  for (auto a : v[cur]) {
    if (s[a.second] * 2 > n) {
      res += (n - 2 * s[a.second]) * a.first.second;
      cur = a.second;
      return true;
    }
  }
  return false;
}
int main() {
  for (int i = 2; i <= 5000; ++i) isPrime[i] = true;
  for (int i = 2; i <= 5000; ++i)
    if (isPrime[i])
      for (int j = i * 2; j <= 5000; j += i) {
        isPrime[j] = false;
      }
  v.push_back({});
  s.push_back(0);
  dep.push_back(0);
  map<int, int> primes;
  for (int i = 1; i <= 5000; ++i) {
    primess(i, primes);
    auto it = primes.rbegin();
    int pos = 0;
    while (it != primes.rend()) {
      int n = it->first;
      int c = it->second;
      while (c) {
        if (v[pos].size() && v[pos].back().first.first == n) {
          c -= v[pos].back().first.second;
          pos = v[pos].back().second;
        } else {
          v[pos].push_back({{n, c}, v.size()});
          dep.push_back(dep[pos] + c);
          pos = v.size();
          v.push_back({});
          s.push_back(0);
          c = 0;
        }
      }
      it++;
    }
    w[i] = pos;
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    s[w[k]]++;
    res += dep[w[k]];
  }
  dfs(0);
  while (improve())
    ;
  cout << res << "\n";
}
