#include<iostream> #include<cstdio> #define maxn 1000010 #define ll long long usingnamespacestd;
constint p = 1000000007;
ll pow_mod(ll x, ll n){ ll s = 1; for (; n; n >>= 1) { if (n & 1) s = s * x % p; x = x * x % p; } return s; }
int n, m, num[maxn];
int pri[maxn], c1, mu[maxn]; bool isp[maxn]; voidinit_isp(int n){ mu[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++c1] = i, mu[i] = -1; for (int j = 1; j <= c1 && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) break; mu[i * pri[j]] = -mu[i]; } } }
int f[maxn], g[maxn], ans; intmain(){ cin >> n; for (int i = 1; i <= n; ++i) { int x; cin >> x; ++num[x]; m = max(m, x); } init_isp(m); for (int i = 2; i <= m; ++i) { int s = 0; for (int j = i; j <= m; j += i) s += num[j]; if (s) f[i] = s * pow_mod(2, s - 1) % p; } for (int i = 2; i <= m; ++i) for (int j = i; j <= m; j += i) g[i] = (g[i] + f[j] * mu[j / i]) % p; for (int i = 2; i <= m; ++i) ans = (ans + (ll) i * g[i]) % p; cout << ans << "\n"; return0; }