#include <bits/stdc++.h>
using namespace std;
int inf_int = 1e9 + 7;
long long inf_ll = 4e18;
const long double PI = 3.141592653589793;
const long double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 1;
int phi[maxn];
int nprim[maxn];
int U[maxn];
int mark[maxn];
int cnt[maxn];
long long dp[maxn];
int main() {
  for (int i = 1; i < maxn; ++i) {
    phi[i] = i;
    U[i] = 1;
  }
  int val = 2;
  dp[1] = 1;
  for (int i = 2; i < maxn; ++i) {
    dp[i] = dp[i - 1] * 2;
    if (dp[i] >= MOD) dp[i] -= MOD;
    dp[i] += val;
    if (dp[i] >= MOD) dp[i] -= MOD;
    val *= 2;
    if (val >= MOD) val -= MOD;
  }
  for (int i = 2; i < maxn; ++i) {
    if (!nprim[i]) {
      for (int j = i; j < maxn; j += i) {
        nprim[j] = true;
        U[j] *= -1;
        if (j % (i * i) == 0) U[j] = 0;
        phi[j] /= i;
        phi[j] *= (i - 1);
      }
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  long long ans = 0;
  for (int i = 1; i < maxn; ++i) {
    long long col = 0;
    for (int j = i; j < maxn; j += i) {
      col += cnt[j];
    }
    ans += dp[col] * phi[i];
    ans -= U[i] * dp[col];
    if (abs(ans) >= MOD) ans %= MOD;
    if (ans < 0) ans += MOD;
  }
  cout << ans;
}
