#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10, mod = 1e9 + 7;
long long two[maxn], ans[maxn], num[maxn], Ans;
int main() {
  two[0] = 1;
  for (long long i = 1; i < maxn; i++) two[i] = (two[i - 1] * 2) % mod;
  long long n;
  cin >> n;
  for (long long x, i = 0; i < n; i++) {
    cin >> x;
    num[x]++;
  }
  for (long long i = 2; i < maxn; i++)
    for (long long j = i + i; j < maxn; j += i) {
      num[i] += num[j];
      num[i] %= mod;
    }
  for (long long i = maxn - 6; i > 1; i--) {
    ans[i] = num[i] * two[num[i] - 1];
    ans[i] %= mod;
    for (long long j = i + i; j < maxn; j += i) {
      ans[i] -= ans[j];
      ans[i] %= mod;
    }
    Ans = (Ans + ans[i] * i) % mod;
  }
  cout << (Ans + mod) % mod;
}
