#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const long long mod = 1000000007;
int lpf[maxn], mu[maxn];
void pre() {
  memset(lpf, 0, sizeof(lpf));
  for (int i = 2; i < maxn; i++) {
    if (!lpf[i]) {
      for (int j = i; j < maxn; j += i) {
        if (!lpf[j]) lpf[j] = i;
      }
    }
  }
  mu[1] = 1;
  for (int i = 2; i < maxn; i++) {
    int x = lpf[i];
    if ((i / x) % x == 0)
      mu[i] = 0;
    else
      mu[i] = -mu[i / x];
  }
}
long long f[maxn];
long long modPow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) (ans *= a) %= mod;
    (a *= a) %= mod;
    b >>= 1;
  }
  return ans;
}
void add(vector<pair<int, int> > &arr, int ind, int num) {
  if (ind == arr.size()) {
    f[num]++;
    return;
  }
  add(arr, ind + 1, num);
  int tmp = num;
  for (int i = 1; i <= arr[ind].second; i++) {
    tmp *= arr[ind].first;
    add(arr, ind + 1, tmp);
  }
}
void addToArr(int x) {
  vector<pair<int, int> > arr;
  while (x > 1) {
    if (arr.empty() || arr.back().first != lpf[x])
      arr.push_back({lpf[x], 1});
    else
      arr.back().second++;
    x /= lpf[x];
  }
  add(arr, 0, 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(30);
  pre();
  int n, x;
  cin >> n;
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    cin >> x;
    addToArr(x);
  }
  for (int i = 0; i < maxn; i++) {
    if (f[i]) (f[i] *= modPow(2, f[i] - 1)) %= mod;
  }
  long long ans = 0;
  for (int i = maxn - 1; i > 1; i--) {
    long long ret = 0;
    for (int j = i; j < maxn; j += i) {
      if (mu[j / i] == 1) (ret += f[j]) %= mod;
      if (mu[j / i] == -1) (ret += mod - f[j]) %= mod;
    }
    (ans += (ret * i)) %= mod;
  }
  cout << ans << endl;
}
