#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAXN = 1e6 + 10;
int n;
int a[MAXN];
long long p[MAXN];
long long f[MAXN];
long long ans = 0;
void init() {
  p[0] = 1;
  for (int i = 1; i <= n; i++) p[i] = p[i - 1] * 2 % M;
}
int main() {
  scanf("%d", &n);
  init();
  int x;
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    a[x]++;
  }
  for (int i = MAXN - 1; i > 1; i--) {
    x = 0;
    for (int j = i; j < MAXN; j += i) x += a[j];
    if (x) {
      f[i] = x * p[x - 1] % M;
      for (int j = 2 * i; j < MAXN; j += i) f[i] = (f[i] - f[j] + M) % M;
      ans = (ans + f[i] * i) % M;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
