#include <bits/stdc++.h>
using ll = long long;
const int C = 300001, D = 20, M = 1000000007;
int dp[C][D], primes[C];
inline ll pow(ll a, ll b, ll M) {
  if (b == 0) return 1;
  ll c = 1;
  while (b > 0) {
    if (b % 2 == 1) c = (c * a) % M;
    b /= 2;
    a = (a * a) % M;
  }
  return c;
}
void fac_creation(ll fac[], ll af[], int n) {
  int i;
  fac[0] = 1, af[0] = 1;
  for (i = 1; i < n; i++) fac[i] = (fac[i - 1] * i) % M;
  for (i = 1; i < n; i++) af[i] = pow(fac[i], M - 2, M);
}
void supfactor(int* pr, int v) {
  int i, j;
  pr[1] = 1;
  for (i = 2; i * i < v; i++) {
    if (pr[i] == 0) {
      for (j = i; j < v; j += i) {
        if (pr[j] == 0) pr[j] = i;
      }
    }
  }
  for (; i < v; i++)
    if (pr[i] == 0) pr[i] = i;
}
int find_divs(int* pr, int a, int dv[], int s[]) {
  int ln = 0;
  while (a > 1) {
    if (ln == 0 || pr[a] != dv[ln - 1])
      dv[ln] = pr[a], s[ln] = 1, ln++;
    else
      s[ln - 1]++;
    a /= pr[a];
  }
  return ln;
}
ll fac[C], afac[C], pw[C];
inline ll cn(int n, int k) {
  return (((fac[n] * afac[k]) % M) * afac[n - k]) % M;
}
int csc[D], dvs[D], s[D];
int main() {
  ll res = 0, summa_cn;
  int n, i, j, ij, jj, summa = 0, maxi = 0, a, ln, left, right;
  pw[0] = 1;
  for (i = 1; i < C; i++) pw[i] = (pw[i - 1] * 2) % M;
  scanf("%d", &n);
  supfactor(primes, C);
  fac_creation(fac, afac, C);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    ln = find_divs(primes, a, dvs, s);
    for (j = 0; j < ln; j++) dp[dvs[j]][s[j]]++;
  }
  for (i = 2; i < C; i++) {
    if (primes[i] != i) continue;
    for (j = 0; j < D; j++) {
      summa += dp[i][j];
      if (dp[i][j] > 0) maxi = j;
    }
    if (summa == 0) continue;
    dp[i][0] += n - summa;
    for (j = 0; j < D; j++) {
      csc[j] = dp[i][j];
      if (j > 0) csc[j] += csc[j - 1];
    }
    for (j = 0; j <= maxi; j++) {
      if (dp[i][j] == 0) continue;
      for (ij = 0; ij < j; ij++) {
        left = csc[ij];
        right = csc[maxi] - csc[ij] - 1;
        summa_cn = pw[left];
        for (jj = 0; jj <= left - 1 && jj <= right; jj++) {
          summa_cn = (summa_cn - cn(left, jj)) % M;
          res = (res + ((1ll * dp[i][j] * summa_cn) % M) * cn(right, jj)) % M;
        }
      }
      for (ij = j + 1; ij <= maxi; ij++) {
        left = csc[ij - 1] - 1;
        right = csc[maxi] - csc[ij - 1];
        summa_cn = pw[right] - cn(right, 0);
        for (jj = 0; jj <= left && jj <= right - 2; jj++) {
          summa_cn = (summa_cn - cn(right, jj + 1)) % M;
          res = (res + ((1ll * dp[i][j] * cn(left, jj)) % M) * summa_cn) % M;
        }
      }
    }
    summa = 0, maxi = 0;
  }
  if (res < 0) res += M;
  printf("%lld\n", res);
  return 0;
}
