#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();
  return data * w;
}
int n, p[1000005], vis[1000005], fac[1000005], inv[1000005], sum[1000005];
const int mod = 1e9 + 7;
int C(int n, int m) { return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod; }
const int M = 3e5;
int KSM(int x, int k) {
  int tmp = 1, y = x;
  for (int i = k; i; i >>= 1, y = 1ll * y * y % mod)
    if (i & 1) tmp = 1ll * tmp * y % mod;
  return tmp;
}
vector<int> v[300005];
int main() {
  for (int i = 2; i <= M; i++) {
    if (!vis[i]) p[++p[0]] = i;
    for (int j = 1; j <= p[0]; j++) {
      if (i * p[j] > M) break;
      vis[i * p[j]] = 1;
      if (i % p[j] == 0) break;
    }
  }
  n = read();
  for (int i = 1; i <= n; i++) {
    int x = read();
    for (int j = 1; j <= p[0] && p[j] * p[j] <= x; ++j)
      if (x % p[j] == 0) {
        int sum = 0;
        while (x % p[j] == 0) x /= p[j], ++sum;
        v[p[j]].push_back(sum);
      }
    if (x > 1) v[x].push_back(1);
  }
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
  inv[n] = KSM(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
  sum[0] = 1;
  for (int i = 1; i <= n - 1; i++) sum[i] = (sum[i - 1] + C(n - 1, i)) % mod;
  int ans = 0;
  for (int i = 1; i <= M; i++) {
    if (v[i].empty()) continue;
    sort(v[i].begin(), v[i].end());
    int k = n - v[i].size();
    for (auto p : v[i]) {
      ++k;
      ans = (ans +
             p * (1ll * sum[n - 1] - sum[k - 1] - (k >= 2 ? sum[k - 2] : 0))) %
            mod;
    }
  }
  cout << (-ans + mod) % mod << '\n';
  return 0;
}
