#include <bits/stdc++.h>
using namespace std;
const int N = (int)5e5 + 5;
const int M = (int)1e7 + 5;
const int base = (int)1e9 + 7;
int n, a[N], cnt[M], pw[N], d[M], dp[M], mx;
vector<int> divisors;
void init() {
  d[0] = d[1] = 1;
  for (int i = 2; i <= mx; ++i)
    if (!d[i]) {
      d[i] = i;
      for (int j = i + i; j <= mx; j += i) d[j] = (!d[j] ? i : min(d[j], i));
    }
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) pw[i] = (pw[i - 1] * 2) % base;
  for (int i = 2; i <= mx; ++i)
    for (int j = i + i; j <= mx; j += i) cnt[i] += cnt[j];
  for (int i = mx; i > 1; --i) {
    dp[i] = (pw[cnt[i]] - 1 + base) % base;
    for (int j = i + i; j <= mx; j += i) dp[i] = (dp[i] - dp[j] + base) % base;
  }
}
int calc(int idx = 0, int mult = 1, int cnt2 = 0) {
  if (idx >= ((int)divisors.size())) {
    if (mult == 1) return 0;
    int tmp = cnt[mult] * (cnt2 % 2 == 1 ? 1 : -1);
    return tmp;
  }
  int ret = 0;
  for (int i = 0; i < 2; ++i)
    ret += calc(idx + 1, mult * (i == 1 ? divisors[idx] : 1), cnt2 + i);
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), mx = max(mx, a[i]), ++cnt[a[i]];
  init();
  long long res = 0;
  for (int i = 2; i <= mx; ++i)
    if (dp[i]) {
      divisors.clear();
      int x = i;
      while (x > 1) {
        int tmp = d[x];
        while (x % tmp == 0) x /= tmp;
        divisors.push_back(tmp);
      }
      res =
          (res + (long long)dp[i] * (long long)(n - calc()) % (long long)base) %
          (long long)base;
    }
  printf("%I64d", res);
  return 0;
}
