#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000006;
const int P = 1000000007;
int n;
int a[maxN], pos[maxN], f[maxN];
int ans;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[x]++;
  }
  pos[0] = 1;
  for (int i = 1; i <= n; i++) pos[i] = (1LL * pos[i - 1] * 2) % P;
  for (int i = maxN - 1; i > 1; i--) {
    int x = 0;
    for (int j = i; j < maxN; j += i) x += a[j];
    f[i] = 1LL * x * pos[x - 1] % P;
    for (int j = i + i; j < maxN; j += i) f[i] = (f[i] - f[j] + P) % P;
    ans = (ans + 1LL * f[i] * i) % P;
  }
  cout << ans << endl;
  return 0;
}
