#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000001;
const long long int LLINF = 1000000000000000001LL;
vector<long long int> fact, revFact;
long long int expo(long long int a, long long int n, long long int mod) {
  if (!n) return 1;
  long long int temp = expo(a, n / 2, mod);
  temp = (temp * temp) % mod;
  if (n % 2) {
    temp = (temp * a) % mod;
  }
  return temp;
}
long long int revMod(long long int a, long long int mod) {
  return expo(a, mod - 2, mod);
}
int binom(int n, int m) {
  int ans = fact[n];
  ans = ((long long int)ans * revFact[m]) % MOD;
  ans = ((long long int)ans * revFact[n - m]) % MOD;
  return ans;
}
vector<long long int> getBinoms(int n) {
  vector<long long int> res = {0};
  for (int i = (0); i <= (n); ++i) {
    res.push_back(binom(n, i));
  }
  return res;
}
vector<long long int> getPrefs(vector<long long int> tab) {
  for (int i = (1); i <= ((int)(tab).size() - 1); ++i) {
    tab[i] = (tab[i] + tab[i - 1]) % MOD;
  }
  return tab;
}
void solve(int n, map<int, int> &cnt, long long int &ans,
           vector<long long int> &prefPref) {
  int left = 0, right = n;
  for (auto &e : cnt) {
    right -= e.second;
    ans = (ans + e.first * (prefPref[left + e.second] - prefPref[left])) % MOD;
    ans =
        (ans - e.first * (prefPref[right + e.second] - prefPref[right])) % MOD;
    if (ans < 0) ans += MOD;
    left += e.second;
  }
}
void prep(int N) {
  fact = {1};
  for (int i = (1); i <= (N); ++i) {
    fact.push_back((fact.back() * i) % MOD);
  }
  for (int i = (0); i <= ((int)(fact).size() - 1); ++i) {
    revFact.push_back(revMod(fact[i], MOD));
  }
}
vector<int> makeSieve(int N) {
  vector<int> sieve(N + 1);
  for (int i = (2); i <= (N); ++i) sieve[i] = i;
  for (int i = (2); i <= (N); ++i)
    if (sieve[i] == i)
      for (int j = 2 * i; j <= N; j += i) sieve[j] = min(sieve[j], i);
  return sieve;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  map<int, map<int, int> > cnt;
  const int MAXN = 300000;
  prep(MAXN);
  vector<int> sieve = makeSieve(MAXN);
  vector<long long int> prefPref = getPrefs(getPrefs(getBinoms(n - 1)));
  for (int _ = (1); _ <= (n); ++_) {
    int val;
    cin >> val;
    while (val > 1) {
      int p = sieve[val], ex = 0;
      while (val % p == 0) {
        val /= p;
        ex++;
      }
      cnt[p][ex]++;
    }
  }
  long long int ans = 0;
  for (auto &forPrime : cnt) {
    int sum = 0;
    for (auto &e : forPrime.second) sum += e.second;
    if (sum < n) {
      forPrime.second[0] = n - sum;
    }
    solve(n, forPrime.second, ans, prefPref);
  }
  cout << ans;
  return 0;
}
