#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 500;
long long fac[maxn];
long long rfac[maxn];
long long a[maxn];
long long am[maxn];
long long poww(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ans;
}
inline long long ent(int n, int k) {
  if (k < 0 || k > n) return 0;
  return (((fac[n] * rfac[k]) % mod) * rfac[n - k]) % mod;
}
long long vec[maxn][22];
long long n;
long long ml[maxn];
inline long long find_f(long long c) {
  if (n - c < c) {
    c = n - c;
  }
  if (ml[c] != -1) {
    return ml[c];
  }
  long long ans = 0;
  long long pr = 0;
  long long sa = poww(2, n - c);
  for (long long i = 0; i <= c; i++) {
    pr = (pr + ent(n - c, i) * i) % mod;
    sa = (sa - ent(n - c, i)) % mod;
    long long res = (pr + ((sa * i) % mod));
    ans += (res * ent(c, i)) % mod;
  }
  ans %= mod;
  ml[c] = ans;
  return ans;
}
int main() {
  fill(ml, ml + maxn, -1);
  fac[0] = 1;
  rfac[0] = 1;
  for (long long i = 1; i < maxn; i++) {
    fac[i] = (fac[i - 1] * i) % mod;
    rfac[i] = poww(fac[i], mod - 2);
  }
  for (long long i = 2; i < maxn; i++) {
    if (am[i] == 0) {
      for (long long j = i; j < maxn; j += i) {
        am[j] = i;
      }
    }
  }
  long long ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    while (a[i] != 1) {
      long long v = am[a[i]];
      long long cnt = 0;
      while (a[i] % v == 0) {
        cnt++;
        a[i] /= v;
      }
      vec[v][cnt]++;
    }
  }
  for (long long t = 2; t < maxn; t++) {
    if (am[t] == t) {
      long long y = 0;
      for (long long j = 1; j < 22; j++) {
        y += vec[t][j];
      }
      vec[t][0] = n - y;
    }
  }
  for (long long t = 2; t < maxn; t++) {
    if (vec[t][0] != n && am[t] == t) {
      long long c = 0;
      for (long long i = 0; i < 21 && c != n; i++) {
        c += vec[t][i];
        ans += find_f(c);
      }
    }
  }
  cout << ((ans % mod) + mod) % mod;
}
