Problem: [Æsir - CHAOS](https://soundcloud.com/kivawu/aesir-chaos)

[Æsir - V.](https://soundcloud.com/kivawu/aesir-v)

"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.

The time right now...... 00:01:12......

It's time."

The emotion samples are now sufficient. After almost 3 years, it's time for Ivy to awake her bonded sister, Vanessa.

The system inside A.R.C.'s Library core can be considered as an undirected graph with infinite number of processing nodes, numbered with all positive integers (1, 2, 3, …). The node with a number x (x > 1), is directly connected with a node with number (x)/(f(x)), with f(x) being the lowest prime divisor of x.

Vanessa's mind is divided into n fragments. Due to more than 500 years of coma, the fragments have been scattered: the i-th fragment is now located at the node with a number k_i! (a factorial of k_i).

To maximize the chance of successful awakening, Ivy decides to place the samples in a node P, so that the total length of paths from each fragment to P is smallest possible. If there are multiple fragments located at the same node, the path from that node to P needs to be counted multiple times.

In the world of zeros and ones, such a requirement is very simple for Ivy. Not longer than a second later, she has already figured out such a node.

But for a mere human like you, is this still possible?

For simplicity, please answer the minimal sum of paths' lengths from every fragment to the emotion samples' assembly node P.

Input

The first line contains an integer n (1 ≤ n ≤ 10^6) — number of fragments of Vanessa's mind.

The second line contains n integers: k_1, k_2, …, k_n (0 ≤ k_i ≤ 5000), denoting the nodes where fragments of Vanessa's mind are located: the i-th fragment is at the node with a number k_i!.

Output

Print a single integer, denoting the minimal sum of path from every fragment to the node with the emotion samples (a.k.a. node P).

As a reminder, if there are multiple fragments at the same node, the distance from that node to P needs to be counted multiple times as well.

Examples

Input


3
2 1 4


Output


5


Input


4
3 1 4 4


Output


6


Input


4
3 1 4 1


Output


6


Input


5
3 1 4 1 5


Output


11

Note

Considering the first 24 nodes of the system, the node network will look as follows (the nodes 1!, 2!, 3!, 4! are drawn bold):

<image>

For the first example, Ivy will place the emotion samples at the node 1. From here:

  * The distance from Vanessa's first fragment to the node 1 is 1. 
  * The distance from Vanessa's second fragment to the node 1 is 0. 
  * The distance from Vanessa's third fragment to the node 1 is 4. 



The total length is 5.

For the second example, the assembly node will be 6. From here:

  * The distance from Vanessa's first fragment to the node 6 is 0. 
  * The distance from Vanessa's second fragment to the node 6 is 2. 
  * The distance from Vanessa's third fragment to the node 6 is 2. 
  * The distance from Vanessa's fourth fragment to the node 6 is again 2. 



The total path length is 6.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
char getc() {
  return (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
}
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::getc;
using io ::gi;
using io ::print;
using io ::putc;
template <class T>
void upmax(T &x, T y) {
  x = x > y ? x : y;
}
template <class T>
void upmin(T &x, T y) {
  x = x < y ? x : y;
}
const int N = 5005, V = 5000;
bool np[N];
int p[N], pid[N], minFac[N], pc = 0;
void pre() {
  np[0] = np[1] = true;
  for (int i = 2; i <= V; i++) {
    if (!np[i]) p[++pc] = i, pid[i] = pc;
    for (int j = 1; j <= pc && i * p[j] <= V; j++) {
      np[i * p[j]] = true;
      minFac[i * p[j]] = p[j];
      if (i % p[j] == 0) break;
    }
  }
}
int fa[N * 2], len[N * 2], cnt[N];
int tr[N], sz[N * 2];
void modify(int p) {
  p = pc - p + 1;
  for (; p <= pc; p += p & -p) ++tr[p];
}
int query(int p) {
  p = pc - p + 1;
  int res = 0;
  for (; p; p ^= (p & -p)) res += tr[p];
  return res;
}
struct Edge {
  int v, w;
  Edge() {}
  Edge(int _v, int _w) : v(_v), w(_w) {}
};
vector<Edge> G[N * 2];
int nc = 1;
long long res = 0;
int Node[N], Sum[N];
int getDepth(int x) {
  int res = 0;
  while (x != 1) res += len[x], x = fa[x];
  return res;
}
void build() {
  nc = 1;
  sz[nc] = cnt[1] + cnt[0];
  int facSum = 0;
  for (int i = 2; i <= V; i++) {
    if (!np[i]) {
      int now = ++nc;
      fa[now] = 1;
      len[now] = ++facSum;
      sz[now] = cnt[i];
      modify(pid[i]);
      res += 1LL * facSum * cnt[i];
      continue;
    }
    int v = i, facCnt = 0;
    while (np[v]) v /= minFac[v], ++facCnt;
    ++facCnt;
    int com = query(pid[v]), diff = facSum - com;
    int x = nc;
    while (diff >= len[x]) diff -= len[x], x = fa[x];
    if (diff == 0) {
      int now = ++nc;
      fa[now] = x;
      facSum += facCnt;
      len[now] = facSum - com;
      sz[now] = cnt[i];
    } else {
      int p = ++nc;
      fa[p] = fa[x];
      len[p] = len[x] - diff;
      fa[x] = p;
      len[x] = diff;
      int now = ++nc;
      fa[now] = p;
      facSum += facCnt;
      len[now] = facSum - com;
      sz[now] = cnt[i];
    }
    v = i;
    while (np[v]) modify(pid[minFac[v]]), v /= minFac[v];
    modify(pid[v]);
    res += 1LL * facSum * cnt[i];
  }
}
void dfs(int x, int fa) {
  for (const Edge &e : G[x]) {
    if (e.v == fa) continue;
    dfs(e.v, x);
    sz[x] += sz[e.v];
  }
}
int main() {
  int n;
  gi(n);
  for (int i = 1, x; i <= n; i++) gi(x), ++cnt[x];
  pre();
  build();
  for (int i = nc; i >= 2; i--) G[fa[i]].emplace_back(i, len[i]);
  dfs(1, 1);
  int p = 1;
  bool flag = true;
  while (flag) {
    flag = false;
    for (const Edge &e : G[p]) {
      if (sz[e.v] > (n >> 1)) {
        res -= 1LL * e.w * ((sz[e.v] << 1) - n);
        p = e.v;
        flag = true;
        break;
      }
    }
  }
  printf("%lld\n", res);
  return 0;
}