#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int Maxn = 1e6 + 10;
const int Mod = 1e9 + 7;
long long a[Maxn];
long long b[Maxn], p[Maxn];
int n, z;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &z);
    a[z]++;
  }
  long long ans = 0, x = 1;
  for (int i = 0; i <= 1e6; ++i) {
    b[i] = x;
    x = (x * 2) % Mod;
  }
  for (int i = 2; i <= 1e6; ++i) p[i] = i;
  for (int i = 2; i <= 1e6; ++i)
    for (int j = i + i; j <= 1e6; j += i) p[j] -= p[i];
  for (long long i = 2; i <= 1e6; i++) {
    long long cnt = 0;
    for (int j = i; j <= 1e6; j += i) cnt += a[j];
    if (cnt == 0) continue;
    ans += (cnt * p[i]) % Mod * b[cnt - 1] % Mod;
    ans %= Mod;
  }
  printf("%I64d\n", ans);
  return 0;
}
