#include <bits/stdc++.h>
using namespace std;
int a[300001];
long long num[300001];
long long sum[300001], ctr[300001][2];
int pri[300005], d[300005], cnt = 0;
bool isp[300005];
int fac[300005], inv[300005];
vector<int> vec[300005];
inline void getp() {
  int i, j;
  for (i = 2; i <= 300000; i++) {
    if (!isp[i]) {
      pri[++cnt] = i;
      d[i] = cnt;
    }
    for (j = 1; j <= cnt && i * pri[j] <= 300000; j++) {
      isp[pri[j] * i] = 1;
      if (i % pri[j] == 0) {
        break;
      }
    }
  }
}
inline int ksm(int a, int b) {
  long long tp = a, res = 1ll;
  while (b) {
    if (b & 1) {
      res *= tp;
      res %= 1000000007;
    }
    tp *= tp;
    tp %= 1000000007;
    b >>= 1;
  }
  return ((int)(res));
}
inline int cal(int a, int b) {
  if (a < b) {
    return 0;
  }
  return (((((long long)(fac[a])) * ((long long)(inv[b]))) % 1000000007) *
          ((long long)(inv[a - b]))) %
         1000000007;
}
int main() {
  int n, i, j;
  getp();
  scanf("%d", &n);
  fac[0] = inv[0] = 1;
  for (i = 1; i <= 300000; i++) {
    fac[i] = (((long long)(fac[i - 1])) * ((long long)(i))) % 1000000007;
    inv[i] = ksm(fac[i], 1000000007 - 2);
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (j = 1; pri[j] <= min(600, a[i]); j++) {
      if (a[i] % pri[j] == 0) {
        int num = 0;
        while (a[i] % pri[j] == 0) {
          a[i] /= pri[j];
          num++;
        }
        vec[j].push_back(num);
      }
    }
    if (a[i] != 1) {
      vec[d[a[i]]].push_back(1);
    }
  }
  for (i = 0; i < n; i++) {
    ctr[i][0] = cal(n - 1, i + 1);
    ctr[i][1] = cal(n - 1, i);
  }
  long long ans = 0;
  for (i = 1; i <= cnt; i++) {
    if (vec[i].size() == 0) {
      continue;
    }
    int pos = n - vec[i].size() + 1;
    sort(vec[i].begin(), vec[i].end());
    for (j = 0; j < vec[i].size(); j++) {
      num[pos + j] += vec[i][j];
    }
  }
  sum[0] = 0;
  for (j = 1; j <= n; j++) {
    sum[j] = sum[j - 1] + num[j];
  }
  for (j = 1; j <= n; j++) {
    int l = j - 1;
    ans += ((long long)(sum[n] - sum[j] - num[j] * ((long long)(n - j))) *
            ((long long)(ctr[l][1]))) %
           1000000007;
    if (ans >= 1000000007) {
      ans -= 1000000007;
    }
    ans += (((long long)(num[j] * ((long long)(j - 1)) - sum[j - 1])) *
            ((long long)(ctr[l][0]))) %
           1000000007;
    if (ans >= 1000000007) {
      ans -= 1000000007;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
