#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000100;
const int mod = 1000000007;
int bj[Maxn], p[Maxn], tot, cnt[Maxn], n, x, mu[Maxn];
long long h[Maxn], ans;
void ycl(int x) {
  mu[1] = 1;
  for (int i = 2; i <= x; i++) {
    if (!bj[i]) {
      p[++tot] = i;
      mu[i] = -1;
    }
    int j = 0, temp;
    while ((temp = i * p[++j]) <= x) {
      bj[temp] = 1;
      if (i % p[j] == 0) break;
      mu[temp] = -mu[i];
    }
  }
}
long long modd(long long x) { return x < 0 ? x + mod : x >= mod ? x - mod : x; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i < Maxn; i++)
    for (int j = i + i; j < Maxn; j += i) cnt[i] += cnt[j];
  h[1] = 1;
  for (int i = 2; i <= n; i++) h[i] = modd(h[i - 1] << 1);
  for (int i = 1; i <= n; i++) h[i] = h[i] * i % mod;
  ycl(Maxn - 1);
  for (int i = 2; i < Maxn; i++)
    for (int j = i, temp = 1; j < Maxn; j += i, temp++)
      ans = modd(ans + mu[temp] * h[cnt[j]] * i % mod);
  cout << ans << endl;
}
