#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000, MAXN = 1e6 + 5;
long long ctr[MAXN], av[MAXN], tab[MAXN], p[MAXN], mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> tab[i];
    av[tab[i]]++;
  }
  p[0] = 1;
  for (int i = 1; i <= 1000 * 1000; i++) {
    p[i] = (p[i - 1] * 2) % mod;
  }
  for (int i = 2; i <= 1000 * 1000; i++) {
    for (int j = i; j <= 1000 * 1000; j += i) {
      ctr[i] = (ctr[i] + av[j]) % mod;
    }
    if (ctr[i]) ctr[i] = (ctr[i] * p[ctr[i] - 1]) % mod;
  }
  long long res = 0;
  for (int i = 1000 * 1000; i > 1; i--) {
    if (ctr[i]) {
      for (int j = 2 * i; j <= 1000 * 1000; j += i) {
        ctr[i] = ((ctr[i] - ctr[j]) % mod + mod) % mod;
      }
      res = (res + ctr[i] * i) % mod;
    }
  }
  cout << res << "\n";
}
