#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e6 + 20;
const long long inf = 1e18;
const int mod = 1e9 + 7;
int n, ans, bin[mxn], A[mxn], dp[mxn];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  bin[0] = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    A[a]++;
    bin[i] = bin[i - 1] * 2 % mod;
  }
  for (int i = 1000000; i > 1; i--) {
    int a = 0;
    for (int j = i; j <= 1000000; j += i) a += A[j];
    if (a) {
      dp[i] = 1LL * a * bin[a - 1] % mod;
      for (int j = i * 2; j <= 1000000; j += i)
        dp[i] = (dp[i] - dp[j] + mod) % mod;
      ans = (1LL * dp[i] * i + ans) % mod;
    }
  }
  cout << ans << '\n';
  return 0;
}
