#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define f(i, x, y) for(int i = x; i < y; i++)
#define int long long
const int mod = 1e9 + 7;
const int inf = 1e5;
using namespace std;
main()
{
int n; cin>>n;
int arr[n+1];
int gcd[1000001];
memset(gcd, 0, sizeof(gcd));
f(i, 1, n+1)
{
cin>>arr[i];
}
int p2[1000001];
p2[0] = 1;
f(i, 1, 1000001)
p2[i] = (p2[i-1] * 2) % mod;
f(i, 1, n+1)
{
int x = sqrt(arr[i]);
gcd[arr[i]]++;
f(j, 2, x+1)
{
if(arr[i] % j ==0)
{
gcd[j]++;
gcd[arr[i]/j]++;
}
}
if(x * x == arr[i])
gcd[x]--;
}
/* f(i, 2, 1000001)
{
for(int j = 2; i * j <= 1000000; j++)
gcd[i] += gcd[i*j];
}
*/
int ans[1000001];
memset(ans, 0, sizeof(ans));
for(int i = 1000000; i > 1; i--)
{
ans[i] = gcd[i] * p2[max(gcd[i] - 1, (int)0)];
for(int j = 2; i * j <= 1000000; j++)
ans[i] = (ans[i] - ans[i*j] + mod) % mod;
}
int res = 0;
f(i, 2, 1000001)
res = ((ans[i] * i) % mod + res) % mod;
cout<<res;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBmKGksIHgsIHkpIGZvcihpbnQgaSA9IHg7IGkgPCB5OyBpKyspCiNkZWZpbmUgaW50IGxvbmcgbG9uZwpjb25zdCAgaW50IG1vZCA9IDFlOSArIDc7CmNvbnN0IGludCBpbmYgPSAxZTU7CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgptYWluKCkKewogICAgaW50IG47IGNpbj4+bjsKICAgIGludCBhcnJbbisxXTsKICAgIGludCBnY2RbMTAwMDAwMV07CiAgICBtZW1zZXQoZ2NkLCAwLCBzaXplb2YoZ2NkKSk7CgogICAgZihpLCAxLCBuKzEpCiAgICB7CiAgICAgICAgY2luPj5hcnJbaV07CiAgICB9CiAgICAKICAgIGludCBwMlsxMDAwMDAxXTsKICAgIHAyWzBdID0gMTsKICAgIGYoaSwgMSwgMTAwMDAwMSkKICAgICAgICBwMltpXSA9IChwMltpLTFdICogMikgJSBtb2Q7CiAgICAKICAgIGYoaSwgMSwgbisxKQogICAgewogICAgICAgIGludCB4ID0gc3FydChhcnJbaV0pOwogICAgICAgIGdjZFthcnJbaV1dKys7CiAgICAgICAgCiAgICAgICAgZihqLCAyLCB4KzEpCiAgICAgICAgewogICAgICAgICAgICBpZihhcnJbaV0gJSBqID09MCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ2NkW2pdKys7CiAgICAgICAgICAgICAgICBnY2RbYXJyW2ldL2pdKys7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYoeCAqIHggPT0gYXJyW2ldKQogICAgICAgICAgICBnY2RbeF0tLTsKICAgIH0KCgovKiAgICBmKGksIDIsIDEwMDAwMDEpCiAgICB7CiAgICAgICAgZm9yKGludCBqID0gMjsgaSAqIGogPD0gMTAwMDAwMDsgaisrKQogICAgICAgICAgICBnY2RbaV0gKz0gZ2NkW2kqal07CiAgICB9CiovICAgIAogICAgaW50IGFuc1sxMDAwMDAxXTsKICAgIG1lbXNldChhbnMsIDAsIHNpemVvZihhbnMpKTsKCiAgICBmb3IoaW50IGkgPSAxMDAwMDAwOyBpID4gMTsgaS0tKSAKICAgIHsKICAgICAgICBhbnNbaV0gPSBnY2RbaV0gKiBwMlttYXgoZ2NkW2ldIC0gMSwgKGludCkwKV07CiAgICAgICAgCiAgICAgICAgZm9yKGludCBqID0gMjsgaSAqIGogPD0gMTAwMDAwMDsgaisrKQogICAgICAgICAgICBhbnNbaV0gPSAoYW5zW2ldIC0gYW5zW2kqal0gKyBtb2QpICUgbW9kOwogICAgCiAgICB9CgogICAgaW50IHJlcyA9IDA7CiAgICAKICAgIGYoaSwgMiwgMTAwMDAwMSkKICAgICAgICByZXMgPSAoKGFuc1tpXSAqIGkpICUgbW9kICsgcmVzKSAlIG1vZDsKICAgIGNvdXQ8PHJlczsgICAgCn0=