#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long _x = 0;
  int _ch = getchar(), _f = 1;
  for (; !isdigit(_ch) && (_ch != '-') && (_ch != EOF); _ch = getchar())
    ;
  if (_ch == '-') {
    _f = 0;
    _ch = getchar();
  }
  for (; isdigit(_ch); _ch = getchar()) _x = _x * 10 + _ch - '0';
  return _f ? _x : -_x;
}
void write(long long _x) {
  if (_x >= 10)
    write(_x / 10), putchar(_x % 10 + '0');
  else
    putchar(_x + '0');
}
inline void wrt(long long _x, char _p) {
  if (_x < 0) putchar('-'), _x = -_x;
  write(_x);
  if (_p) putchar(_p);
}
int n;
int a[300005];
int fac[300005], inv[300005];
int sum[300005], pre[300005];
int c[300005][22];
inline int qpow(int x, int k = 1000000007 - 2) {
  int ans = 1;
  for (; k; k >>= 1, x = 1ll * x * x % 1000000007)
    if (k & 1) ans = 1ll * ans * x % 1000000007;
  return ans;
}
bool vis[300005];
int pri[300005], tp;
void euler(int mx) {
  for (int i = int(2); i <= (int)(mx); i++) {
    if (!vis[i]) pri[++tp] = i;
    for (int j = 1; j <= tp && i * pri[j] <= mx; j++) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) break;
    }
  }
}
inline int C(int n, int m) {
  return 1ll * fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
void predo() {
  fac[0] = fac[1] = inv[0] = inv[1] = 1;
  for (int i = int(2); i <= (int)(n); i++) {
    fac[i] = 1ll * fac[i - 1] * i % 1000000007;
    inv[i] =
        1ll * (1000000007 - 1000000007 / i) * inv[1000000007 % i] % 1000000007;
  }
  for (int i = int(1); i <= (int)(n); i++)
    inv[i] = 1ll * inv[i - 1] * inv[i] % 1000000007;
  sum[0] = 1;
  for (int i = int(1); i <= (int)(n); i++)
    sum[i] = (sum[i - 1] + C(n - 1, i)) % 1000000007;
  pre[1] = -sum[n - 2];
  for (int i = int(2); i <= (int)(n - 1); i++)
    pre[i] =
        ((long long)pre[i - 1] + sum[n - 1] - sum[n - i] - sum[n - i - 1]) %
        1000000007;
  pre[n] = (pre[n - 1] + sum[n - 1] - 1) % 1000000007;
}
void init() {
  for (int i = int(1); i <= (int)(tp); i++) c[i][0] = n;
  for (int i = int(1); i <= (int)(n); i++) {
    int x = a[i];
    for (int j = 1; j <= tp && pri[j] * pri[j] <= x; j++)
      if (x % pri[j] == 0) {
        c[j][0]--;
        int tt = 0;
        while (x % pri[j] == 0) tt++, x /= pri[j];
        c[j][tt]++;
      }
    if (x > 1) {
      int p = lower_bound(pri + 1, pri + 1 + tp, x) - pri;
      c[p][0]--, c[p][1]++;
    }
  }
}
int solve() {
  int ans = 0;
  for (int i = int(1); i <= (int)(tp); i++) {
    for (int j = 1, S = c[i][0]; S < n; S += c[i][j], j++) {
      ans = (ans + 1ll * (pre[S + c[i][j]] - pre[S]) * j % 1000000007) %
            1000000007;
    }
  }
  return (ans + 1000000007) % 1000000007;
}
int main() {
  n = rd();
  int Mx = 0;
  for (int i = int(1); i <= (int)(n); i++) a[i] = rd(), Mx = max(Mx, a[i]);
  euler(Mx);
  predo();
  init();
  wrt(solve(), '\n');
}
