#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const long long int Mod = 1e9 + 7;
bool isp[maxn];
int sign[maxn], cnt[maxn];
long long int P[maxn];
int n;
long long int func(int x) { return (x * P[x - 1]) % Mod; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(isp, true, sizeof isp);
  fill(sign, sign + maxn, 1);
  isp[0] = isp[1] = false;
  for (int i = 2; i < maxn; i++)
    if (isp[i])
      for (int j = i; j < maxn; j += i) {
        isp[j] = i == j;
        if ((j / i) % i == 0)
          sign[j] = 0;
        else
          sign[j] *= -1;
      }
  P[0] = 1;
  for (int i = 1; i < maxn; i++) P[i] = (P[i - 1] << 1) % Mod;
  cin >> n;
  for (int x, i = 0; 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];
  long long int ans = 0;
  for (int i = 2; i < maxn; i++) {
    long long int rc = 0;
    for (int j = i; j < maxn; j += i)
      rc = (rc + sign[j / i] * func(cnt[j])) % Mod;
    ans += rc * i;
    ans %= Mod;
  }
  ans = (ans + Mod) % Mod;
  cout << ans << endl;
}
