#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
int prime[10101010 / 10], flag[10101010], np, cnt[10101010], dd[10101010];
void prepare() {
  for (int i = 2; i < 10101010; i++) {
    if (!flag[i]) prime[np++] = i, flag[i] = i, dd[i] = 1;
    for (int j = 0; j < np && prime[j] * i < 10101010; j++) {
      flag[i * prime[j]] = prime[j];
      if (i % prime[j] == 0) break;
      dd[i * prime[j]] = dd[i] + 1;
    }
  }
}
int power(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int a[1010100], p[1010100], qf, qb, q[1010100], f[111];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  prepare();
  for (int i = 0; i < n; i++) {
    int deg = 0;
    for (int v = a[i]; v > 1;) {
      int u = flag[v];
      while (v % u == 0) v /= u;
      f[deg++] = u;
    }
    qb = 0;
    q[qb++] = 1;
    for (int j = 0; j < deg; j++) {
      for (int z = qb, k = 0; k < z; k++) {
        q[qb++] = q[k] * f[j];
      }
    }
    for (int j = 1; j < qb; j++) cnt[q[j]]++;
  }
  sort(a, a + n);
  for (int i = p[0] = 1; i <= n; i++)
    p[i] = (long long)p[i - 1] * 2 % 1000000007;
  int midans = 0;
  for (int i = 2; i < 10101010; i++) {
    int cc = 0, aa = 0;
    for (int u = i; u > 1;) {
      int v = flag[u];
      while (u % v == 0) u /= v, cc++;
      aa++;
      if (cc > aa) break;
    }
    if (cc > aa) continue;
    if (cc & 1)
      midans = (midans + p[cnt[i]] - 1) % 1000000007;
    else
      midans = (midans - p[cnt[i]] + 1) % 1000000007;
  }
  midans = (1000000007 + midans) % 1000000007;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int deg = 0;
    for (int v = a[i]; v > 1;) {
      int u = flag[v];
      while (v % u == 0) v /= u;
      f[deg++] = u;
    }
    qb = 0;
    q[qb++] = 1;
    for (int j = 0; j < deg; j++) {
      for (int z = qb, k = 0; k < z; k++) {
        q[qb++] = q[k] * f[j];
      }
    }
    for (int j = 1; j < qb; j++) cnt[q[j]]--;
    long long mid = 0, tmp = midans;
    for (int j = 1; j < qb; j++) {
      if (dd[q[j]] & 1)
        mid = (mid - p[cnt[q[j]]] + 1);
      else
        mid = (mid + p[cnt[q[j]]] - 1);
      if (dd[q[j]] & 1) {
        tmp = (tmp - p[cnt[q[j]] + 1] + p[cnt[q[j]]]);
      } else {
        tmp = (tmp + p[cnt[q[j]] + 1] - p[cnt[q[j]]]);
      }
    }
    ans += (tmp + mid) % 1000000007;
    ans = (1000000007 + ans % 1000000007) % 1000000007;
    for (int j = 1; j < qb; j++) cnt[q[j]]++;
  }
  printf("%d\n", ans);
  return 0;
}
