#include <bits/stdc++.h>
const int MAX_N = (int)5e5 + 4, MAX_M = (int)1e7 + 4;
const double eps = 1e-6;
const int mod = (int)1e9 + 7;
using namespace std;
int n;
int a[MAX_N];
bool pr[MAX_M];
int lp[MAX_M], mu[MAX_M];
inline void sieve() {
  for (int i = 2; i < MAX_M; i++) {
    if (pr[i]) continue;
    lp[i] = i;
    if (1ll * i * i < MAX_M)
      for (int j = i * i; j < MAX_M; j += i)
        if (!pr[j]) pr[j] = 1, lp[j] = i;
  }
  mu[1] = 1;
  for (int i = 2; i < MAX_M; i++) {
    if (i == lp[i])
      mu[i] = -1;
    else if (!mu[i / lp[i]] || lp[i] == lp[i / lp[i]])
      mu[i] = 0;
    else
      mu[i] = (-1) * mu[i / lp[i]];
  }
}
vector<int> add;
vector<pair<int, int> > first;
void rec(int v, int id, int now, vector<int> &add) {
  if (v == int((first).size())) {
    add.push_back(now);
    return;
  }
  rec(v + 1, id, now, add);
  for (int i = 1; i <= first[v].second; i++) {
    now *= first[v].first;
    rec(v + 1, id, now, add);
  }
}
inline void fact(int id, int x) {
  first.clear();
  while (x > 1) {
    if (first.empty() || first.back().first != lp[x])
      first.push_back(make_pair(lp[x], 1));
    else
      first.back().second++;
    x /= lp[x];
  }
  add.clear();
  rec(0, id, 1, add);
}
int cnt[MAX_M], all;
unordered_set<int> q;
int ans;
int two[MAX_N];
inline int calc(int id) {
  fact(id, a[id]);
  int nw = all;
  for (auto i : add) {
    nw = (nw - mu[i] * two[cnt[i] - 1]) % mod;
    if (nw < 0) nw += mod;
  }
  nw = two[n - 1] - 1 - nw;
  if (nw < 0) nw += mod;
  for (auto i : add) {
    if (i == 1) continue;
    nw = (nw + mu[i] * (two[cnt[i] - 1] - 1)) % mod;
    if (nw < 0) nw += mod;
  }
  return nw;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sieve();
  for (int i = 1; i <= n; i++) {
    fact(i, a[i]);
    for (auto j : add) cnt[j]++, q.insert(j);
  }
  two[0] = 1;
  for (int i = 1; i <= n; i++) two[i] = 2ll * two[i - 1] % mod;
  for (auto i : q) {
    all = (all + mu[i] * (two[cnt[i]] - 1)) % mod;
    if (all < 0) all += mod;
  }
  for (int i = 1; i <= n; i++) ans = (ans + calc(i)) % mod;
  printf("%d\n", ans);
  return 0;
}
