#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define N 1000005
#define MOD 1000000007
#define cout2(x, y) cout << x << " " << y << endl
using namespace std;
int frec[N], dp[N];
int a[N/10];
int cta[N], t[N];
int main() {
int n, var = 2;
dp[1] = 1;
for(int i = 2; i < N; i++){
dp[i] = 2 * dp[i - 1];
if(dp[i] >= MOD)dp[i] %= MOD;
dp[i] += var;
if(dp[i] >= MOD)dp[i] %= MOD;
var *= 2;
if(var >= MOD)var %= MOD;
}
scanf("%d", &n);
int maxi = 0;
for(int i = 0; i < n; i++){
scanf("%d", &a[i]);
maxi = max(maxi, a[i]);
cta[a[i]]++;
}
long long ans = 0;
for(long long i = 2; i <= maxi; i++){
long long total = 0;
for(long long j = i; j <= maxi; j += i)total += cta[j];
t[i] = total;
}
for(long long i = 2; i <= maxi; i++){
long long total = 0;
ans += (i * dp[t[i]])%MOD;
for(long long j = i; j <= maxi; j += i){// n -> j
if(t[j] > 0){
if(i != j){
ans -= (i * dp[t[j]])%MOD;
if(ans < 0)ans += MOD;
}
}
}
}
printf("%I64d\n", ans);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcGIoeCkgcHVzaF9iYWNrKHgpCiNkZWZpbmUgYWxsKHgpIHguYmVnaW4oKSwgeC5lbmQoKQojZGVmaW5lIE4gMTAwMDAwNQojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgY291dDIoeCwgeSkgY291dCA8PCB4IDw8ICIgIiA8PCB5IDw8IGVuZGwKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKaW50IGZyZWNbTl0sIGRwW05dOwppbnQgYVtOLzEwXTsKaW50IGN0YVtOXSwgdFtOXTsKCmludCBtYWluKCkgewoKCWludCBuLCB2YXIgPSAyOwoJCglkcFsxXSA9IDE7Cglmb3IoaW50IGkgPSAyOyBpIDwgTjsgaSsrKXsKCQkKCQlkcFtpXSA9IDIgKiBkcFtpIC0gM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