#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 7;
const int M = 5e5 + 7;
const int Q = 1e9 + 7;
inline int pls(int x, int y) { return (x + y) % Q; }
inline int mns(int x, int y) { return pls(x, Q - y); }
inline int mul(int x, int y) { return 1LL * x * y % Q; }
inline int pwr(int x, int tms) {
  int res = 1;
  for (; tms > 0; tms >>= 1) {
    if (tms & 1) res = mul(res, x);
    x = mul(x, x);
  }
  return res;
}
inline int inv(int x) { return pwr(x, Q - 2); }
const int iv2 = 500000004;
inline int ri() {
  int x = 0;
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f ? x : -x;
}
int n;
int a[M];
int prime[N], p[N], mu[N], cnt;
bool notprime[N];
int lg[512];
int s[N], A, B, C, ans;
void init() {
  notprime[1] = 1;
  mu[1] = 1;
  int i, j, k, t;
  for (i = 2; i < N; ++i) {
    if (!notprime[i]) {
      prime[++cnt] = i;
      p[i] = i;
      mu[i] = -1;
    }
    for (j = 1; j <= cnt; ++j) {
      if (1LL * prime[j] * i >= N) break;
      t = prime[j] * i;
      notprime[t] = 1;
      p[t] = prime[j];
      if (i % prime[j] == 0) {
        mu[t] = 0;
        break;
      }
      mu[t] = -mu[i];
    }
  }
  for (i = 1; i < N; ++i)
    if (mu[i] == -1) mu[i] = Q - 1;
}
void upd(int d) {
  static int q[10];
  int tt = 0;
  static int val[512];
  while (d > 1) {
    int x = p[d];
    q[tt++] = x;
    while (d % x == 0) d /= x;
  }
  int i, x, mask = (1 << tt) - 1;
  for (val[0] = 1, i = 0; i <= mask; ++i) {
    if (i != 0)
      x = val[i] = val[i ^ (1 << lg[i])] * ((i >> lg[i] & 1) ? q[lg[i]] : 1);
    else
      x = 1;
    int tp = s[x] + 1;
    A = pls(A, mul(mu[x], tp));
    s[x] = pls(s[x], tp);
  }
}
void solve(int d) {
  static int q[10];
  int tt = 0;
  static int val[512];
  while (d > 1) {
    int x = p[d];
    q[tt++] = x;
    while (d % x == 0) d /= x;
  }
  int i, x, mask = (1 << tt) - 1;
  C = A;
  for (val[0] = 1, i = 0; i <= mask; ++i) {
    if (i != 0)
      x = val[i] = val[i ^ (1 << lg[i])] * ((i >> lg[i] & 1) ? q[lg[i]] : 1);
    else
      x = 1;
    int tp = mul(iv2, mns(s[x], 1));
    C = mns(C, mul(mu[x], mns(s[x], tp)));
    if (x > 1) C = pls(C, mul(Q - mu[x], tp));
  }
  ans = pls(ans, mns(B, C));
}
int main() {
  int i;
  n = ri();
  B = mns(pwr(2, n - 1), 1);
  for (i = 1; i <= n; ++i) a[i] = ri();
  init();
  for (lg[1] = 0, i = 2; i < 512; ++i) lg[i] = lg[i >> 1] + 1;
  for (i = 1; i <= n; ++i) upd(a[i]);
  for (i = 1; i <= n; ++i) solve(a[i]);
  printf("%d\n", ans);
  return 0;
}
