#include <bits/stdc++.h>
const int maxn = 1000005, mod = 1000000007;
int n, cnt, maxx, ans;
int c[maxn], p[maxn], a[maxn], mul[maxn];
inline int max(int a, int b) { return a > b ? a : b; }
int main() {
  p[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    if (c[i] == 0) p[++cnt] = i;
    for (int j = 1; j <= cnt; j++) {
      if (i * p[j] > 1000000) break;
      c[i * p[j]] = 1;
      if (i % p[j] == 0) break;
    }
  }
  scanf("%d", &n);
  mul[0] = 1;
  for (int i = 1; i <= n; i++) mul[i] = 2ll * mul[i - 1] % mod;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[x]++, maxx = max(maxx, x);
  }
  for (int i = 1; i <= cnt; i++)
    for (int j = maxx / p[i]; j >= 1; j--) a[j] = (a[j] + a[j * p[i]]) % mod;
  for (int i = 1; i <= maxx; i++)
    if (a[i] > 0) a[i] = 1ll * a[i] * mul[a[i] - 1] % mod;
  for (int i = 1; i <= cnt; i++)
    for (int j = 1; p[i] * j <= maxx; j++)
      a[j] = (a[j] - a[p[i] * j] + mod) % mod;
  for (int i = 2; i <= maxx; i++) ans = (ans + 1ll * a[i] * i % mod) % mod;
  printf("%d\n", ans);
  return 0;
}
