#include <bits/stdc++.h>
inline int getint() {
  register char ch;
  while (!isdigit(ch = getchar()))
    ;
  register int x = ch ^ '0';
  while (isdigit(ch = getchar())) x = (((x << 2) + x) << 1) + (ch ^ '0');
  return x;
}
const int N = 3e5 + 1, P = 25998, mod = 1e9 + 7;
bool vis[N];
std::vector<int> v[P];
int p[P], id[N], a[N], fac[N], ifac[N], s[N];
inline void sieve(const int &n) {
  for (register int i = 2; i <= n; i++) {
    if (!id[i]) {
      id[i] = ++p[0];
      p[id[i]] = i;
    }
    for (register int j = 1; j <= p[0] && i * p[j] <= n; j++) {
      id[i * p[j]] = -1;
      if (i % p[j] == 0) break;
    }
  }
}
void exgcd(const int &a, const int &b, int &x, int &y) {
  if (!b) {
    x = 1, y = 0;
    return;
  }
  exgcd(b, a % b, y, x);
  y -= a / b * x;
}
inline int inv(const int &x) {
  int ret, tmp;
  exgcd(x, mod, ret, tmp);
  return (ret % mod + mod) % mod;
}
inline int C(const int &n, const int &m) {
  return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main() {
  const int n = getint();
  int max_a = 0;
  for (register int i = 1; i <= n; i++) {
    a[i] = getint();
    max_a = std::max(max_a, a[i]);
  }
  sieve(max_a);
  for (register int i = fac[0] = 1; i <= n; i++) {
    fac[i] = 1ll * fac[i - 1] * i % mod;
  }
  ifac[n] = inv(fac[n]);
  for (register int i = n; i >= 1; i--) {
    ifac[i - 1] = 1ll * ifac[i] * i % mod;
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= p[0] && p[j] * p[j] <= a[i]; j++) {
      if (a[i] % p[j] != 0) continue;
      int tmp = 0;
      for (; a[i] % p[j] == 0; tmp++) {
        a[i] /= p[j];
      }
      v[j].push_back(tmp);
    }
    if (a[i] != 1) v[id[a[i]]].push_back(1);
  }
  for (register int i = s[0] = 1; i < n; i++) {
    s[i] = (s[i - 1] + C(n - 1, i)) % mod;
  }
  int ans = 0;
  for (register int i = 1; i <= p[0]; i++) {
    if (v[i].empty()) continue;
    std::sort(v[i].begin(), v[i].end());
    const int t = n - v[i].size();
    for (register int j = t; j < (int)v[i].size() + t; j++) {
      (ans += 1ll * v[i][j - t] * (s[j - 1] - s[n - j - 2] + mod) % mod) %= mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}
