#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
const int M = 1e7 + 5;
const int mod = 1e9 + 7;
int p, n, mx, cnt, ans, tmp, SUM, sum, tw[N], a[N];
int mn[M], pri[M], miu[M], num[M];
bool np[M];
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int max(int a, int b) { return a > b ? a : b; }
void init(int n) {
  np[1] = true;
  for (int i = 2; i <= n; i++) {
    if (!np[i]) {
      pri[++cnt] = i;
      miu[i] = -1;
    }
    for (int j = 1; j <= cnt && 1ll * i * pri[j] <= n; j++) {
      np[i * pri[j]] = true;
      mn[i * pri[j]] = pri[j];
      if (i % pri[j])
        miu[i * pri[j]] = -miu[i];
      else {
        miu[i * pri[j]] = 0;
        break;
      }
    }
  }
}
void work() {
  for (int k = 1; k <= n; k++) {
    tmp = a[k];
    cnt = 0;
    while (mn[tmp]) {
      pri[++cnt] = mn[tmp];
      while (mn[tmp] == pri[cnt]) tmp /= pri[cnt];
    }
    if (!cnt || pri[cnt] != tmp) pri[++cnt] = tmp;
    if (p == 2) sum = 0;
    for (int i = 1; i <= (1 << cnt) - 1; i++) {
      int now = 1;
      for (int j = 1; j <= cnt; j++)
        if (i & (1 << (j - 1))) now *= pri[j];
      if (p == 1)
        num[now]++;
      else
        sum = (sum - miu[now] * (tw[num[now]] - 1)) % mod;
    }
    if (p == 2) ans = ((ans + SUM) % mod - sum) % mod;
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), mx = max(mx, a[i]);
  tw[0] = 1;
  for (int i = 1; i <= n; i++) tw[i] = (tw[i - 1] << 1) % mod;
  init(mx);
  p = 1;
  work();
  for (int i = 2; i <= mx; i++) SUM = (SUM - miu[i] * (tw[num[i]] - 1)) % mod;
  p = 2;
  work();
  printf("%d", (ans + mod) % mod);
  return 0;
}
