#include <bits/stdc++.h>
using namespace std;
vector<int> g[((long long)3e5 + 1)];
int n, f[((long long)3e5 + 1)];
long long Fac[((long long)3e5 + 1)], Inv[((long long)3e5 + 1)];
long long mul[((long long)3e5 + 1)];
long long qpow(long long a, int exp) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = ans * a % ((long long)1e9 + 7);
    a = a * a % ((long long)1e9 + 7);
    exp >>= 1;
  }
  return ans;
}
long long Ckn(int n, int k) {
  if (n < k) return 0;
  if (k < 0) return 0;
  long long ans = Inv[k] * Inv[n - k] % ((long long)1e9 + 7);
  ans = ans * Fac[n] % ((long long)1e9 + 7);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 2; i < ((long long)3e5 + 1); ++i)
    if (!f[i])
      for (int j = i; j < ((long long)3e5 + 1); j += i) f[j] = i;
  cin >> n;
  Fac[0] = Inv[0] = 1;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    while (x > 1) {
      int P = f[x], e = 0;
      while (!(x % P)) {
        x /= P;
        ++e;
      }
      g[P].push_back(e);
    }
    Fac[i] = Fac[i - 1] * i % ((long long)1e9 + 7);
    Inv[i] = qpow(Fac[i], ((long long)1e9 + 7) - 2);
  }
  mul[0] = 1;
  for (int i = 1; i < n; ++i)
    mul[i] = (mul[i - 1] + Ckn(n - 1, i)) % ((long long)1e9 + 7);
  long long ans = 0;
  for (int i = 2; i < ((long long)3e5 + 1); ++i) {
    sort(g[i].begin(), g[i].end());
    int p = n - g[i].size() + 1;
    for (int x : g[i]) {
      ans = (ans +
             x * (2 * (p > 1 ? mul[p - 2] : 0) + Ckn(n - 1, p - 1) -
                  qpow(2, n - 1)) +
             ((long long)1e9 + 7)) %
            ((long long)1e9 + 7);
      ++p;
    }
  }
  cout << ans << endl;
}
