#include <bits/stdc++.h>
using namespace std;
const int MN = 5e5 + 5, MM = 1e7 + 5, mod = 1e9 + 7;
int n, lim, s[MM], two[MN], a[MN], tot[MM], g[MM], pr[MM / 10], cnt, mu[MM],
    vis[MM];
inline void inc(int &x, int y) { x = x + y < mod ? x + y : x + y - mod; }
inline void dec(int &x, int y) { x = x - y >= 0 ? x - y : x - y + mod; }
inline void prework(int n) {
  mu[1] = 1;
  for (int i = 2; i <= n; ++i) {
    if (!vis[i]) pr[++cnt] = i, mu[i] = -1;
    for (int j = 1; j <= cnt && i * pr[j] <= n; ++j) {
      vis[i * pr[j]] = 1;
      if (i % pr[j] == 0) {
        mu[i * pr[j]] = 0;
        break;
      } else
        mu[i * pr[j]] = -mu[i];
    }
  }
}
int main() {
  scanf("%d", &n);
  two[0] = 1;
  for (int i = 1; i <= 500000; ++i) two[i] = 2ll * two[i - 1] % mod;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    ++tot[a[i]];
  }
  lim = *max_element(a + 1, a + 1 + n);
  prework(lim);
  for (int i = 1; i <= cnt; ++i)
    for (int j = lim / pr[i]; j; --j) tot[j] += tot[j * pr[i]];
  for (int i = 1; i <= lim; ++i)
    g[i] = (1ll * tot[i] * mu[i] % mod + mod) % mod;
  for (int i = 1; i <= cnt; ++i)
    for (int j = 1; j * pr[i] <= lim; ++j) inc(g[j * pr[i]], g[j]);
  for (int i = 1; i <= lim; ++i) s[i] = two[tot[i]] - 1;
  for (int i = cnt; i; --i)
    for (int j = 1; j * pr[i] <= lim; ++j) dec(s[j], s[j * pr[i]]);
  int ans = 0;
  for (int i = lim; i > 1; --i) inc(ans, 1ll * s[i] * g[i] % mod);
  printf("%d\n", ans);
  return 0;
}
