#include <bits/stdc++.h>
const int maxn = 300005;
const long long mod = 1e9 + 7;
using namespace std;
int cnt[maxn], a[30];
bool np[maxn];
int fact[maxn], inv[maxn];
int least[maxn];
bool mark[2][maxn];
int mem[2][maxn];
int sum(int a, int b) {
  int c = a + b;
  while (c < 0) c += mod;
  while (c >= mod) c -= mod;
  return c;
}
int mul(const int &a, const int &b) { return (1LL) * a * b % mod; }
int bpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    b /= 2;
    a = mul(a, a);
  }
  return res;
}
long long comb(int n, int k) {
  if (n < k) return 0;
  return mul(fact[n], mul(inv[k], inv[n - k]));
}
void init() {
  fact[0] = inv[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fact[i] = mul(fact[i - 1], i);
    inv[i] = mul(inv[i - 1], bpow(i, mod - 2));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  init();
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x, cnt[x]++;
  int ans = 0;
  for (int i = 2; i < maxn; i++) {
    if (np[i]) continue;
    fill(a, a + 30, 0);
    int mx = 0, tot = 0;
    for (int j = i; j < maxn; j += i) {
      np[j] = true;
      if (cnt[j] == 0) continue;
      int t, tmp = j;
      for (t = 0; tmp % i == 0; tmp /= i, t++)
        ;
      a[t] += cnt[j];
      tot += cnt[j];
      mx = max(mx, t);
    }
    a[0] += n - tot;
    mx++;
    if (tot == 0) continue;
    for (int it = 0; it < 2; it++) {
      int L = 0;
      for (int i = 0; i + 1 < mx; i++) {
        L += a[i];
        if (mark[it][L]) {
          ans = sum(ans, mem[it][L]);
          continue;
        }
        mark[it][L] = true;
        least[n - L + 1] = 0;
        least[n - L] = 1;
        for (int i = n - L - 1; i >= 0; i--)
          least[i] = sum(least[i + 1], comb(n - L, i));
        long long cur = 0;
        for (int ia = 0; ia <= min(L, n - L); ia++)
          cur = sum(cur, mul(ia, mul(comb(L, ia), least[ia + it])));
        ans = sum(ans, mem[it][L] = cur);
      }
      reverse(a, a + mx);
    }
  }
  cout << ans << '\n';
  return 0;
}
