#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   const long long INF = (long long)1e18;   int n;   long long a[11], val[11];   long long dp[1 << 8][1 << 8];   int lastBit[1 << 8];   long long del[11][1 << 8];   long long get(long long v) {     long long i = 2;     long long res = 0;     while (i * i <= v) {       while (v % i == 0) {         res++;         v /= i;       }       i++;     }     if (v > 1) {       res++;     }     return res;   }   long long dfs(int mask1, int mask2) {     if (mask1 == 0 && mask2 == 0) return 0;     if (mask2 == 0 && mask1 != 0) return INF;     long long &res = dp[mask1][mask2];     if (res != -1) return res;     res = INF;     int last = lastBit[mask2];     for (int sub = mask1;; sub = (sub - 1) & mask1) {       if (del[last][sub] != -1) {         res = min(res, dfs(mask1 ^ sub, mask2 ^ (1 << last) ^ sub) + 1 +                            (sub == 0 ? val[last] : del[last][sub]));       }       if (sub == 0) break;     }     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     for (int i = 0; i < n; i++) {       val[i] = get(a[i]);       if (val[i] == 1) val[i] = 0;     }     for (int mask = 0; mask < (1 << n); mask++) {       int last = -1;       for (int i = 0; i < n; i++)         if (mask & (1 << i)) {           last = i;         }       lastBit[mask] = last;     }     for (int i = 0; i < n; i++) {       for (int mask = 0; mask < (1 << n); mask++) {         long long v = a[i];         for (int j = 0; j < n; j++)           if (mask & (1 << j)) {             if (v % a[j] != 0) {               v = -1;               break;             } else {               v /= a[j];             }           }         del[i][mask] = v == -1 ? -1 : get(v);       }     }     memset(dp, -1, sizeof(dp));     long long res = INF;     for (int mask = 1; mask < (1 << n); mask++) {       res = min(res, dfs(((1 << n) - 1) ^ mask, mask) +                          (__builtin_popcountll(mask) == 1 ? 0 : 1));     }     cout << res << endl;     return 0;   }   