#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
vector<int> prime[600201], li[600201];
int n, a[600201], de[40], p[600201];
long long pre[600201], pre2[600201], col[600201], nc[600201];
long long fact[600201];
long long big(long long a, long long p) {
  if (!p) return 1;
  long long t = big(a, p >> 1);
  t = t * t % 1000000007;
  if (p & 1) t = t * a % 1000000007;
  return t;
}
long long rev(long long a) { return big(a, 1000000007 - 2); }
void calc() {
  long long ret = 1;
  for (int i = (0); i <= (n); i++) {
    nc[i] = (ret) % 1000000007;
    ret = ret * (long long)(n - i - 1) % 1000000007 * rev(i + 1) % 1000000007;
  }
  for (int i = (1); i <= (n); i++) pre[i] = (pre[i - 1] + nc[i]) % 1000000007;
  for (int i = (1); i <= (n); i++)
    pre2[i] = (pre2[i - 1] + nc[i - 1]) % 1000000007;
}
long long seg(long long a, long long b) {
  return (pre[b] - pre[a - 1] + 1000000007) % 1000000007;
}
long long seg2(long long a, long long b) {
  return (pre2[b] - pre2[a - 1] + 1000000007) % 1000000007;
}
int main() {
  for (int i = (2); i <= (300000); i++)
    if (!p[i]) {
      for (int j = i; j <= 300000; j += i) {
        prime[j].push_back(i);
        p[i] = 1;
      }
    }
  fact[0] = 1;
  for (int i = (1); i <= (300000 + 300000); i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) scanf("%d", &a[i]);
  for (int i = (1); i <= (n); i++) {
    int w = a[i];
    for (auto Z : prime[a[i]]) {
      int cnt = 0;
      while (w % Z == 0) {
        w /= Z;
        cnt++;
      }
      li[Z].push_back(cnt);
    }
  }
  calc();
  long long ret = 0;
  for (int i = (2); i <= (300000); i++)
    if (li[i].size()) {
      for (int j = (0); j <= (30); j++) de[j] = 0;
      int ma = 0;
      for (auto Z : li[i]) {
        ma = max(ma, Z);
        de[Z]++;
      }
      de[0] = n - li[i].size();
      int pre = de[0], dist = de[0];
      for (int j = (1); j <= (ma); j++) {
        ret = (ret + dist * seg(pre + 1, pre + de[j])) % 1000000007;
        pre += de[j];
        dist += pre;
      }
      pre = n - de[ma];
      dist = de[ma];
      for (int j = (ma - 1); j >= (0); j--) {
        ret = (ret + dist * (seg2(pre - de[j] + 1, pre))) % 1000000007;
        pre -= de[j];
        dist += (n - pre);
      }
    }
  cout << ret << endl;
  return 0;
}
