#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010, p = 1e9 + 7;
int Pow(long long x, int pow) {
  int res = 1;
  while (pow) {
    if (pow & 1) res = (res * x) % p;
    x = (x * x) % p;
    pow >>= 1;
  }
  return res;
}
int inv(int x) { return Pow(x, p - 2); }
int Prime[maxn], Not_Prime[maxn], PToNum[maxn], Primes;
int C[maxn], CSum[maxn], CSSum[maxn];
int t[maxn];
int a[maxn][20];
int ans;
int n;
void Get_Prime() {
  for (int i = 2; i < maxn; i++) {
    if (!Not_Prime[i]) Prime[++Primes] = i, PToNum[i] = Primes;
    for (int j = 1, temp; j <= Primes && (temp = Prime[j] * i) < maxn; j++) {
      Not_Prime[temp] = 1;
      if (i % Prime[j] == 0) break;
    }
  }
}
void Init_Comb() {
  C[0] = CSum[0] = CSSum[0] = 1;
  for (int i = 1; i < n; i++)
    C[i] = ((long long)C[i - 1] * (n - i) % p) * inv(i) % p;
  for (int i = 1; i < n; i++) CSum[i] = (CSum[i - 1] + C[i]) % p;
  for (int i = 1; i < n; i++) CSSum[i] = (CSSum[i - 1] + CSum[i]) % p;
}
void Init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  Get_Prime();
  Init_Comb();
  for (int i = 1; i <= Primes; i++) a[i][0] = n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= Primes && Prime[j] * Prime[j] <= t[i]; j++)
      if (t[i] % Prime[j] == 0) {
        int cnt = 0;
        while (t[i] % Prime[j] == 0) cnt++, t[i] /= Prime[j];
        a[j][cnt]++;
        a[j][0]--;
      }
    if (t[i] > 1) a[PToNum[t[i]]][1]++, a[PToNum[t[i]]][0]--;
  }
}
void Solve() {
  for (int i = 1; i <= Primes; i++)
    if (a[i][0] < n) {
      int cnt = a[i][0];
      for (int j = 1; cnt < n; cnt += a[i][j++]) {
        int res = 0;
        res = (long long)a[i][j] * CSum[n - 1] % p;
        res = ((res + CSum[n - cnt - 1] - 2 * CSSum[n - cnt - 1]) % p + p) % p;
        if (cnt + a[i][j] < n)
          res = ((res - CSum[n - cnt - a[i][j] - 1] +
                  2 * CSSum[n - cnt - a[i][j] - 1] % p) %
                     p +
                 p) %
                p;
        res = (long long)res * j % p;
        ans = (ans + res) % p;
      }
    }
}
int main() {
  Init();
  Solve();
  printf("%d\n", ans);
}
