#include <bits/stdc++.h>
using namespace std;
const int N2 = 1e7 + 5;
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int H[N2], n, i, j, t, k;
int E[N2], A[N], Q[N2], K[N];
long long asd, ans;
vector<int> V[N];
int main() {
  scanf("%d", &n);
  K[0] = 1;
  for (i = 1; i < N; i++) K[i] = K[i - 1] * 2 % mod;
  for (i = 2; i < N2; i++)
    if (!E[i]) {
      E[i] = i;
      if ((long long)i * i >= N2) continue;
      for (j = i * i; j < N2; j += i) E[j] = i;
    }
  for (i = 1; i <= n; i++) {
    scanf("%d", A + i);
    t = A[i];
    int tt;
    if (H[t])
      tt = H[t];
    else {
      H[t] = i;
      tt = i;
      while (E[t]) {
        V[i].push_back(E[t]);
        int r = E[t];
        while (t and t % r == 0) t = t / r;
      }
    }
    for (j = 1; j < (1 << V[tt].size()); j++) {
      int w = 1, e = 0;
      for (k = 0; k < V[tt].size(); k++)
        if (j & (1 << k)) {
          w *= V[tt][k];
          e++;
        }
      if (e & 1)
        asd = (asd + (K[Q[w]] - 1 + mod) % mod) % mod;
      else
        asd = (asd - (K[Q[w]] - 1 + mod) % mod + mod) % mod;
      Q[w]++;
    }
  }
  for (i = 1; i <= n; i++) {
    t = A[i];
    long long q = 0;
    int tt = H[A[i]];
    for (j = 1; j < (1 << V[tt].size()); j++) {
      int w = 1, e = 0;
      for (k = 0; k < V[tt].size(); k++)
        if (j & (1 << k)) {
          w *= V[tt][k];
          e++;
        }
      if (e & 1)
        q = (q + (K[Q[w]] - 1 + mod) % mod) % mod;
      else
        q = (q - (K[Q[w]] - 1 + mod) % mod + mod) % mod;
    }
    ans = (ans + asd + n - q + mod) % mod;
  }
  printf("%lld", ans);
}
