#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
const int MOD = 1e9 + 7 ;
const int N = 1e6 + 20 ;
vector<int> v(N), cnt(N) , dp(N);
int binExp(int a, int b){
int res = 1 ;
a %= MOD ;
while(b){
if(b % 2 == 1){
res *= a;
res %= MOD ;
}
a *= a;
a %= MOD ;
b /= 2 ;
}
return res % MOD ;
}
void solve() {
int n ; cin >> n;
for(int i = 0 ; i < n ; i++){
int x ; cin >> x ;
for(int y = 1 ; y * y <= x ; y++){
if(x % y == 0){
cnt[y]++ ;
if(y *y != x) cnt[x/y]++ ;
}
}
}
for(int i = 0 ; i < N; i++){
if(cnt[i]){
dp[i] = cnt[i] * binExp(2 , cnt[i] - 1);
dp[i] %= MOD ;
}
}
int ans = 0 ;
for(int i = N ; i > 1 ; i--){
for(int j = 2 * i; j < N ; j += i){
dp[i] = (dp[i] - dp[j] + MOD) % MOD ;
}
ans = (ans + i * dp[i]);
ans %= MOD ;
}
cout << ans << endl;
}
signed main() {
faster();
int test = 1 ;
// cin >> test ;
while(test--) solve();
return 0;
}
CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZW5kbCAiXG4iCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGZhc3RlcigpIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgY2luLnRpZShudWxscHRyKTsgY291dC50aWUobnVsbHB0cik7CmNvbnN0IGludCBNT0QgPSAxZTkgKyA3IDsKY29uc3QgaW50IE4gPSAxZTYgKyAyMCA7Cgp2ZWN0b3I8aW50PiB2KE4pLCBjbnQoTikgLCBkcChOKTsKaW50IGJpbkV4cChpbnQgYSwgaW50IGIpewogICAgaW50IHJlcyA9IDEgOwogICAgYSAlPSBNT0QgOwogICAgd2hpbGUoYil7CiAgICAgICAgaWYoYiAlIDIgPT0gMSl7CiAgICAgICAgICAgIHJlcyAqPSBhOwogICAgICAgICAgICByZXMgJT0gTU9EIDsKICAgICAgICB9CiAgICAgICAgYSAqPSBhOwogICAgICAgIGEgJT0gTU9EIDsKICAgICAgICBiIC89IDIgOwogICAgfQogICAgcmV0dXJuIHJlcyAlIE1PRCA7Cn0KCgp2b2lkIHNvbHZlKCkgewogICAgaW50IG4gOyBjaW4gPj4gbjsKICAgIGZvcihpbnQgaSA9IDAgOyBpIDwgbiA7IGkrKyl7CiAgICAgICAgaW50IHggOyBjaW4gPj4geCA7CiAgICAgICAgZm9yKGludCB5ID0gMSA7IHkgKiB5IDw9IHggOyB5KyspewogICAgICAgICAgICBpZih4ICUgeSA9PSAwKXsKICAgICAgICAgICAgICAgIGNudFt5XSsrIDsKICAgICAgICAgICAgICAgIGlmKHkgKnkgIT0geCkgY250W3gveV0rKyA7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgZm9yKGludCBpID0gMCA7IGkgPCBOOyBpKyspewogICAgICAgIGlmKGNudFtpXSl7CiAgICAgICAgICAgIGRwW2ldID0gY250W2ldICogYmluRXhwKDIgLCBjbnRbaV0gLSAxKTsKICAgICAgICAgICAgZHBbaV0gJT0gTU9EIDsKICAgICAgICB9CiAgICB9CiAgICBpbnQgYW5zID0gMCA7CiAgICBmb3IoaW50IGkgPSBOIDsgaSA+IDEgOyBpLS0pewogICAgICAgIGZvcihpbnQgaiA9IDIgKiBpOyBqIDwgTiA7IGogKz0gaSl7CiAgICAgICAgICAgIGRwW2ldID0gKGRwW2ldIC0gZHBbal0gKyBNT0QpICUgTU9EIDsKICAgICAgICB9CiAgICAgICAgYW5zID0gKGFucyArIGkgKiBkcFtpXSk7CiAgICAgICAgYW5zICU9IE1PRCA7CiAgICB9CiAgICBjb3V0IDw8IGFucyA8PCBlbmRsOwp9CgpzaWduZWQgbWFpbigpIHsKICAgIGZhc3RlcigpOwogICAgaW50IHRlc3QgPSAxIDsKICAgIC8vIGNpbiA+PiB0ZXN0IDsKICAgIHdoaWxlKHRlc3QtLSkgICBzb2x2ZSgpOwogICAgcmV0dXJuIDA7Cn0K