#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
const int MOD = 1e9 + 7;
int n, m = 300000;
int fac[N], inv[N], pw2[N], min_prime[N];
int cnt[N][25];
int powi(int a, int b) {
  int c = 1;
  for (; b; b >>= 1, a = 1ll * a * a % MOD)
    if (b & 1) c = 1ll * c * a % MOD;
  return c;
}
int C(int a, int b) { return 1ll * fac[a] * inv[b] % MOD * inv[a - b] % MOD; }
int solve(int cnta, int cntb) {
  int su = 0, v1 = 0, v2 = 0, v3 = pw2[cntb];
  for (int a = 0; a <= cnta; ++a) {
    su = (su + (v1 + 1ll * (v3 - v2 + MOD) * a) % MOD * C(cnta, a)) % MOD;
    if (a <= cntb) {
      v1 = (v1 + 1ll * a * C(cntb, a)) % MOD;
      v2 = (v2 + 1ll * C(cntb, a)) % MOD;
    }
  }
  return su;
}
int main() {
  cin >> n;
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;
  inv[n] = powi(fac[n], MOD - 2);
  for (int i = n - 1; ~i; --i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
  pw2[0] = 1;
  for (int i = 1; i <= n; ++i) pw2[i] = 2 * pw2[i - 1] % MOD;
  for (int i = 2; i <= m; ++i)
    if (!min_prime[i]) {
      min_prime[i] = i;
      for (int j = i + i; j <= m; j += i)
        if (!min_prime[j]) min_prime[j] = i;
    }
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    while (a != 1) {
      int p = min_prime[a], c = 0;
      while (min_prime[a] == p) c++, a /= min_prime[a], cnt[p][c]++;
    }
  }
  int res = 0;
  for (int i = 2; i <= m; ++i)
    if (min_prime[i] == i)
      for (int j = 20; j >= 0; --j)
        res = (res + solve(cnt[i][j], n - cnt[i][j])) % MOD;
  cout << res << endl;
}
