#include <bits/stdc++.h>
using namespace std;
long long int powm(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
vector<int> primes[int(3e5 + 1000)];
bool isprime[int(3e5 + 1000)] = {false};
vector<int> E[int(3e5 + 1000)];
long long int fac[int(3e5 + 1000)], ifac[int(3e5 + 1000)],
    dp[int(3e5 + 1000)] = {0};
int t[int(3e5 + 1000)];
long long int ncr(int n, int r) {
  return ((fac[n] * ifac[n - r]) % int(1e9 + 7) * ifac[r]) % int(1e9 + 7);
}
int main() {
  int n;
  scanf("%d", &n);
  ;
  for (int i = int(1); i <= (int)n; i++) scanf("%d", &t[i]);
  ;
  for (int i = int(1); i <= (int)3e5; i++) {
    if (i > 1) {
      if (primes[i].size() == 0) {
        isprime[i] = true;
        for (int j = i; j <= 3e5; j += i) {
          primes[j].push_back(i);
        }
      }
    }
  }
  fac[0] = fac[1] = 1;
  ifac[0] = ifac[1] = 1;
  for (int i = 2; i <= 3e5; ++i) {
    fac[i] = fac[i - 1];
    fac[i] *= i;
    fac[i] %= int(1e9 + 7);
    ifac[i] = powm(fac[i], int(1e9 + 7) - 2, int(1e9 + 7));
  }
  dp[0] = 0;
  for (int i = 1; i <= 3e5; ++i) {
    dp[i] = dp[i - 1] + ncr(n, i);
    dp[i] %= int(1e9 + 7);
  }
  int P;
  for (int i = int(1); i <= (int)n; i++) {
    for (int j = 0; j < primes[t[i]].size(); ++j) {
      P = primes[t[i]][j];
      E[P].push_back(i);
    }
  }
  long long int pw = powm(2, n - 1, int(1e9 + 7)) - 1;
  int arr[30] = {0};
  int cnt, idx, num, zero, start;
  long long int ans = 0, tmp;
  for (int i = int(1); i <= (int)3e5; i++) {
    if (isprime[i] && E[i].size() > 0) {
      for (int j = 0; j <= 22; ++j) arr[j] = 0;
      for (int j = 0; j < E[i].size(); ++j) {
        idx = E[i][j];
        num = t[idx];
        cnt = 0;
        while (num % i == 0) {
          num /= i;
          cnt++;
        }
        arr[cnt]++;
      }
      zero = n - E[i].size();
      start = 0;
      for (int j = 1; j <= 22; ++j) {
        tmp = 0;
        for (int k = 1; k <= arr[j]; ++k) {
          start++;
          tmp = (tmp + dp[zero + start - 1] - pw) % int(1e9 + 7);
        }
        tmp *= j;
        tmp %= int(1e9 + 7);
        ans += tmp;
        ans %= int(1e9 + 7);
      }
    }
  }
  ans %= int(1e9 + 7);
  ans += int(1e9 + 7);
  ans %= int(1e9 + 7);
  cout << ans << endl;
  return 0;
}
