#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <functional>
#include <queue>
#include <stack>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <string.h>
using namespace std;
#define sorta(x) sort(x.begin(),x.end())
#define sortd(x) sort(x.begin(),x.end(),greater<int>())
#define pb push_back
#define mp make_pair
int main() {
    int n, m; cin >> n >> m;
    vector<int>x(n);
    for (int i = 0; i < n; cin >> x[i++]);
    sorta(x);
    int counter = m, i = 0, sum = 0;
    while (counter>0) {
        sum += x[i++] * -1, counter--;
    }
    cout << max(sum, 0) << endl;
    return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
int a[100];
bool mark[100];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)	cin>>a[i];
	int ans=0;
	for(int i=0;i<m;i++)
	{
		int mini=0;
		int res=0;
		for(int j=0;j<n;j++)
		{
			if(a[j]<mini and !mark[j])
			{
				mini=a[j];
				res=j;
			}
		}
		ans+=mini;
		mark[res]=true;
	}
	cout<<abs(ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
    int n,m,a[100];
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<m;i++) if(a[i]<0) ans-=a[i];
    printf("%d\n",ans);
}


#include <bits/stdc++.h>
using namespace std;
#define len(a) a.length()
#define all(v) v.begin(),v.end()
#define sort(v) sort(v.begin(),v.end())
#define rsort(v) sort(v.rbegin(),v.rend())
#define fords(v) for (auto it=v.begin();it!=v.end();it++)
#define for(n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef map<int ,int> mii;
typedef pair<int , int> pii;
typedef vector<int> vi;
int main()
{
    ios_base::sync_with_stdio(0);
    int m,n;
    cin>>m>>n;
    vi v1(m);
    for(m)
        cin>>v1[i];
    sort(v1);
    int sum=0;
    for (n)
        {
            if(v1[i]>0) break;
            sum+=v1[i];
        }
    cout<<-sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define len(a) a.length()
#define all(v) v.begin(),v.end()
#define sort(v) sort(v.begin(),v.end())
#define rsort(v) sort(v.rbegin(),v.rend())
#define fords(v) for (auto it=v.begin();it!=v.end();it++)
#define for(n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef map<int ,int> mii;
typedef pair<int , int> pii;
typedef vector<int> vi;
int main()
{
    int m,n;
    cin>>m>>n;
    vi v1(m);
    for(m)
        cin >>v1[i];
    sort(v1);
    int sum=0;
    for (n)
        {
            //if(v1[i]>0) break;
            sum+=v1[i];
        }
    cout<<-sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define len(a) a.length()
#define all(v) v.begin(),v.end()
#define sort(v) sort(v.begin(),v.end())
#define rsort(v) sort(v.rbegin(),v.rend())
#define fords(v) for (auto it=v.begin();it!=v.end();it++)
#define for(n) for(int i=0;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef map<int ,int> mii;
typedef pair<int , int> pii;
typedef vector<int> vi;
int main()
{
    int m,n;
    cin>>m>>n;
    vi v1(m);
    for(m)
        cin >>v1[i];
    sort(v1);
    int sum=0;
    for (n)
        {
            if(v1[i]>0) break;
            sum+=v1[i];
        }
    cout<<-sum;
    return 0;
}


#include <cstdio>
#include <algorithm>

int main(){

    int n(0), m(0); scanf("%d %d", &n, &m);
    int *price = new int[n];
    for(int k = 0; k < n; k++){scanf("%d", price + k);}
    std::sort(price, price + n);
    long total(0);
    for(int k = 0; k < m; k++){if(price[k] < 0){total -= price[k];} else{break;}}
    printf("%ld\n", total);
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int x,y,sum=0,mini=10e9,sets=0;
    cin>>x>>y;
    int arr[x];
    for(int i=0 ; i<x ;i++){
        cin>>arr[i];
    }

    for(int i=0 ; i<x ;i++){
    for(int j=i+1 ; j<=x ;j++){
    if(arr[i]>arr[j]){swap(arr[i],arr[j]);}
    }
    }
        for(int i=0 ; i<x ;i++){
        if(arr[i]>0){break;}
        sum+=arr[i];
        ++sets;
        if(sets==y){break;}
        }
        cout<<-sum<<endl;
    return 0;
}


#include<iostream>
# include<string>
# include<vector>
#include <algorithm>
#include <sstream>
#include <math.h>
using namespace std;
int main(){

int n,m,c=0;

cin>>n>>m;

vector<int>x(n);

for(int i=0;i<n;i++)cin>>x[i];

sort(x.begin(),x.end());

for(int i=0;i<m&&x[i]<0;i++)c-=x[i];

cout<<c<<endl;

return 0;

}


# include<iostream>
# include<vector>
#include<sstream>
#include <algorithm>
#include <set>
#include <math.h>
#include <map>
//#include <windows.h>
using namespace std;

int main(){

int n,m,c=0;
cin>>n>>m;
vector<int>x(n);
for(int i=0;i<n;i++)cin>>x[i];

sort(x.begin(),x.end());

for(int i=0;i<m;i++)
{
	if(x[i]<0)c-=x[i];
	else break;
}
cout<<c<<endl;
return 0;
}


#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>

#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<cctype>
#include<map>
#include<set>
#include <iomanip>
#include <sstream>

#define ll long long
#define all(c) (c).begin(),(c).end()
#define SZ(a) int((a).size())
#define pb push_back
using namespace std;
int main()
{
	vector<int>v;
	int N, m;
	cin >> N >> m;
	v.resize(N);
	for (int i = 0; i < SZ(v); i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	int sum = 0;
	for (int i = 0; i < m; i++)
	{
		if (v[i] < 0)
			sum += v[i];

	}
	if (sum < 0)
		sum *= -1;
	cout << sum << '\n';
	return 0;
}


#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>

#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<cctype>
#include<map>
#include<set>
#include <iomanip>
#include <sstream>

#define ll long long
#define all(c) (c).begin(),(c).end()
#define SZ(a) int((a).size())
#define pb push_back
using namespace std;
int main()
{
	vector<int>v;
	int N, m;
	cin >> N >> m;
	v.resize(N);
	for (int i = 0; i < SZ(v); i++)
		cin >> v[i];
	int sum = 0;
	for (int i = 0; i < SZ(v); i++)
	{
		if (v[i] < 0)
			sum += v[i];

	}
	if (sum < 0)
		sum *= -1;
	cout << sum << '\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int oo = 1000010;
const int MOD = 1e9 + 7;
int f[oo], cum[oo], curans[oo];
long long pow(int n, int k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(int n) {
	return (n*pow(2, n-1))%MOD;

}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(cum, 0, sizeof cum);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		if(x != 1) f[x]++;
	}
	long long ans = 0;

	for(int i = oo; i >= 2; --i){
		long long good = f[i];
		long long bad = 0;
		long long t = 0;
		for(int j = 2; i*j < oo; ++j){
			good += f[i*j];
		 	bad += cum[i*j];
			t += curans[i*j]/(i*j);
			t %= MOD;
		}
		cum[i] = (pow(2,good)) - 1 - bad;
		ans += curans[i] = i*get(good) - i*t;
		ans %= MOD;
		curans[i] %= MOD;
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

long long pow(long long n, long long k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(long long n) {
	long long t = (n * pow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = oo; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= oo; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		if(good)
			trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

long long pow(long long n, long long k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(long long n) {
	long long t = (n * pow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = oo - 1; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= 1000000; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		if(good)
			trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const int MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

long long apow(long long n, long long k) {
	if(k == 0) return 1;
	if(k&1) return n*apow(n*n, k/2)%MOD;
	return apow(n*n, k/2) %MOD;
}

long long get(long long n) {
	long long t = (n * apow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		if(x != 1) f[x]++;
	}
	long long ans = 0;

	for(long long i = 1000000; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= 1000000; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);
	}
	cout << ans%MOD << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const int MOD = 1000000007;
long long f[oo];
long long trueset[oo];

long long pow(long long n, long long k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(long long n) {
	long long t = (n * pow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = oo; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= oo; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		if(good)
			trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

int pow(int n, int k) {
  n %= MOD;
	if(k == 0) return 1;
	if(k&1) return (n*(pow(n*n, k/2))%MOD)%MOD;
	return pow(n*n, k/2) %MOD;
}

int get(int n) {
	return (n * pow(2, n-1))%MOD;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = 1000000; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= 1000000; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		if(good)
			trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
int pow[1000010];

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

long long get(long long n) {
	long long t = (n * pow[n-1]);
	fix(t);
	return t;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	pow[0] = 1;
	for(int i = 0; i < oo; ++i) {
	  pow[i] = 2*pow[i-1];
	  pow[i] %= MOD;
	}
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans1 = 0;
  long long ans[1000010];
	for(long long i = oo; i >= 2; --i){
		long long good = f[i];
		ans[i] = 0;
		for(long long j = i + i; j <= oo; j += i){
			good += f[j];
			ans[i] -= ans[j];
			fix(ans[i]);
		}
		ans[i] += get(good);
		fix(ans[i]);
	}

	for(long long i = oo; i >= 2; --i){
	  ans1 += i*ans[i];
	  fix(ans1);
	}
	fix(ans1);
	cout << ans1 << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

int pow(long long n, long long k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

int get(long long n) {
	long long t = (n * pow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = oo; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= oo; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		if(good)
			trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const int oo = 1e6 + 10;
const int MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

long long pow(int n, int k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(int n) {
	return (n*pow(2, n-1))%MOD;

}

inline void fix(long long x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		if(x != 1) f[x]++;
	}
	long long ans = 0;

	for(long long i = 1000000; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= 1000000; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(good);
			fix(t);
		}
		trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);
	}
	cout << ans%MOD << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];
int p[1000010];

long long get(long long n) {
	return (n * p[n-1])%MOD;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
		p[0] = 1;
	for(int i = 1; i < oo; ++i) {
	  p[i] = 2*p[i-1];
	  p[i] %= MOD;
	}
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = 1000000; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= 1000000; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		if(good)
			trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];
long long trueset[oo];

long long pow(long long n, long long k) {
  if(k == -1) return 0;
	if(k == 0) return 1;
	if(k&1) return (n*pow(n*n, k/2))%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(long long n) {
	long long t = (n * pow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	memset(trueset, 0, sizeof trueset);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;

	for(long long i = 1000000; i >= 2; --i){
		long long good = f[i];
		long long t = 0;
		for(long long j = 2; i*j <= 1000000; ++j){
			good += f[i*j];
			t += trueset[i*j];
			fix(t);
		}
		trueset[i] = get(good) - t;
		fix(trueset[i]);
		ans += i*trueset[i];
		fix(ans);

	}
	fix(ans);
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;

const long long oo = 1e6 + 10;
const long long MOD = 1e9 + 7;
long long f[oo];

long long pow(long long n, long long k) {
	if(k == 0) return 1;
	if(k&1) return n*pow(n*n, k/2)%MOD;
	return pow(n*n, k/2) %MOD;
}

long long get(long long n) {
	long long t = (n * pow(2, n-1));
	t %= MOD;
	return t;
}

inline void fix(long long& x) {
	x = (x%MOD + MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(f, 0, sizeof f);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		f[x]++;
	}
	long long ans = 0;
  long long cnt[1000010];
	for(long long i = oo; i >= 2; --i){
		long long good = f[i];
		cnt[i] = 0;
		for(long long j = 2; i*j <= oo; ++j){
			good += f[i*j];
			cnt[i] -= cnt[i*j];
			fix(cnt[i]);
		}
		cnt[i] += get(good);
		fix(cnt[i]);

	}

	for(long long i = oo; i >= 2; --i){
	  ans += i*cnt[i];
	  fix(ans);
	}
	fix(ans);
	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define long long long // for codeforces

const int MAX_PRIME = 1000;
vector<int> primes;
bool isPrime[MAX_PRIME*MAX_PRIME+1];
// sieve of Erastosthenes
void prime_list(){
  const int sz = MAX_PRIME*MAX_PRIME;
  fill(isPrime, isPrime+sz+1, true);
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i*i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  prime_list();
  vector<int> divs(1000001, 0);

  rep(i,n){
    for(int j=1; j*j<=vec[i]; j++) if(vec[i]%j==0){
      divs[j]++;
      if(j*j!=vec[i]) divs[vec[i]/j]++;
    }
  }

  long ans = 0;
  vector<long> pows(n+5);
  pows[0]=1;
  rep(i,n+1) pows[i+1] = pows[i]*2%MOD;

  auto ps = [&](int x){
    vector<int> ret;
    if(isPrime[x]){
      return ret;
    }
    for(auto p : primes) if(x%p==0){
      while(x%p==0){
        x /=p;
      }
      ret.pb(p);
      if(x==0) break;
    }
    return ret;
  };

  repl(i,2,1000001) if(divs[i]>0){
    long b = 0;
    auto vp = ps(i);
    int sz = vp.size();
    rep(mask,1<<sz){
      int tmp = i;
      if(__builtin_popcount(mask)%2) tmp *=-1;
      rep(j,sz) if(mask&(1<<j)) tmp /= vp[j];
      if(b!=1) b += tmp;
    }
    b *= pows[divs[i]-1] * divs[i]%MOD;
    b %= MOD;
    ans += b;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define long long long // for codeforces

vector<int> fac[1000005];
int divs[1000005];
long val[1000005];

int main(){
  int n;
  // cin>>n;
  scanf("%d", &n);

  rep(i,n){
    int v;
    // cin>>v;
    scanf("%d", &v);
    for(int j=1; j*j<=v; j++) if(v%j==0){
      divs[j]++;
      if(j*j!=v) divs[v/j]++;
    }
  }

  long ans = 0;
  vector<long> pows(n+5);
  pows[0]=1;
  rep(i,n+1) pows[i+1] = pows[i]*2%MOD;

  for(int i=1000000; i>=2; i--) if(divs[i]>0){
    val[i] = pows[divs[i]-1] * divs[i]%MOD;
    for(int j=i*2; j<=1000000; j+=i) val[i] -= val[j];
    val[i]%=MOD;
    ans += val[i]*i%MOD;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define long long long // for codeforces

const int MAX_PRIME = 1000;
vector<int> primes;
bool isPrime[MAX_PRIME*MAX_PRIME+1];
// sieve of Erastosthenes
void prime_list(){
  const int sz = MAX_PRIME*MAX_PRIME;
  fill(isPrime, isPrime+sz+1, true);
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i*i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  prime_list();
  vector<int> divs(1000001, 0);

  rep(i,n){
    for(int j=1; j*j<=vec[i]; j++) if(vec[i]%j==0){
      divs[j]++;
      if(j*j!=vec[i]) divs[vec[i]/j]++;
    }
  }

  long ans = 0;
  vector<long> pows(n+5);
  pows[0]=1;
  rep(i,n+1) pows[i+1] = pows[i]*2%MOD;

  auto ps = [&](int x){
    vector<int> ret;
    if(isPrime[x]){
      return ret;
    }
    for(auto p : primes) if(x%p==0){
      while(x%p==0){
        x /=p;
      }
      ret.pb(p);
      if(x==0) break;
    }
    return ret;
  };

  repl(i,2,1000001) if(divs[i]>0){
    long b = 0;
    auto vp = ps(i);
    int sz = vp.size();
    rep(mask,1<<sz){
      int tmp = i;
      if(__builtin_popcount(mask)%2) tmp *=-1;
      rep(j,sz) if(mask&(1<<j)) tmp /= vp[j];
      if(abs(b)!=1) b += tmp;
    }
    b *= pows[divs[i]-1] * divs[i]%MOD;
    b %= MOD;
    ans += b;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define long long long // for codeforces

vector<int> fac[1000005];
int divs[1000005];
long val[1000005];

int main(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  rep(i,n){
    for(int j=1; j*j<=vec[i]; j++) if(vec[i]%j==0){
      divs[j]++;
      if(j*j!=vec[i]) divs[vec[i]/j]++;
    }
  }

  long ans = 0;
  vector<long> pows(n+5);
  pows[0]=1;
  rep(i,n+1) pows[i+1] = pows[i]*2%MOD;

  for(int i=1000000; i>=2; i--) if(divs[i]>0){
    val[i] = pows[divs[i]-1] * divs[i]%MOD;
    for(int j=i*2; j<=1000000; j+=i) val[i] -= val[j];
    val[i]%=MOD;
    ans += val[i]*i%MOD;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define long long long // for codeforces

vector<int> fac[1000005];
int divs[1000005];
long val[1000005];

int main(){
  int n;
  cin>>n;

  rep(i,n){
    long v;
    cin>>v;
    for(int j=1; j*j<=v; j++) if(v%j==0){
      divs[j]++;
      if(j*j!=v) divs[v/j]++;
    }
  }

  long ans = 0;
  vector<long> pows(n+5);
  pows[0]=1;
  rep(i,n+1) pows[i+1] = pows[i]*2%MOD;

  for(int i=1000000; i>=2; i--) if(divs[i]>0){
    val[i] = pows[divs[i]-1] * divs[i]%MOD;
    for(int j=i*2; j<=1000000; j+=i) val[i] -= val[j];
    val[i]%=MOD;
    ans += val[i]*i%MOD;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007
#define long long long // for codeforces

const int MAX_PRIME = 1000;
vector<int> primes;
bool isPrime[MAX_PRIME*MAX_PRIME+1];
// sieve of Erastosthenes
void prime_list(){
  const int sz = MAX_PRIME*MAX_PRIME;
  fill(isPrime, isPrime+sz+1, true);
  isPrime[0]=isPrime[1]=false;
  for(int i=4;i<=sz;i+=2) isPrime[i]=false;
  primes.pb(2);
  for(int i=3; i*i<=sz; i+=2){
    if(isPrime[i]){
      primes.pb(i);
      for(long j=(long)i*i; j<=sz; j+=i) isPrime[j]=false;
    }
  }
}

int main(){
  int n;
  cin>>n;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  prime_list();
  vector<int> divs(1000001, 0);

  rep(i,n){
    for(int j=1; j*j<=vec[i]; j++) if(vec[i]%j==0){
      divs[j]++;
      if(j*j!=vec[i]) divs[vec[i]/j]++;
    }
  }

  long ans = 0;
  vector<long> pows(n+5);
  pows[0]=1;
  rep(i,n+1) pows[i+1] = pows[i]*2%MOD;

  auto ps = [&](int x){
    vector<int> ret;
    if(isPrime[x]){
      return ret;
    }
    for(auto p : primes) if(x%p==0){
      while(x%p==0){
        x /=p;
      }
      ret.pb(p);
      if(x==0) break;
    }
    return ret;
  };

  repl(i,2,1000001) if(divs[i]>0){
    long b = i;
    auto vp = ps(i);
    for(auto p : vp) b -= i/p;
    b *= pows[divs[i]-1] * divs[i]%MOD;
    b %= MOD;
    ans += b;
  }

  ans %= MOD;
  if(ans<0) ans += MOD;

  cout << ans << endl;

  return 0;
}


#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 200005 , A = 1000005;
int n,a[N];
ll dp[A];

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

ll calc(ll n) {
    if(!n) return 0;
    return power(2, n-1)*n%mod;
}

int main()
{

    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++dp[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) dp[i] += dp[j];

    ll ans = 0;
    lpd(i, A-2, 2) {
        dp[i] = calc(dp[i]);
        for(int j = 2*i ; j < A ; j += i)
            dp[i] = (dp[i] - dp[j] + mod)%mod;

        ans = (ans + i*dp[i]%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 3 4 6

 3
 2 4 8

 4
 2 4 6 12

 3
 2 4 6
 */


//============================================================================
// Name        : code.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 205 , A = 1005;
int n,a[N],divs[A];
ll fact[N],revFact[N],form[N];
vi primesFact[A];

ll nCk(int n,int k) {
    if(!k || n == k) return 1;
    if(k < 0 || n <= 0 || k > n) return 0;
    return fact[n]*revFact[n-k]%mod*revFact[k]%mod;
}

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

void init() {
    for(int i = 2; i < A ; ++i) if(!sz(primesFact[i]))
        for(int j = i ; j < A ; j += i) primesFact[j].pb(i);

    fact[0] = fact[1] = revFact[0] = revFact[1] = 1;
    lp(i, 2, N-2)
        fact[i] = fact[i-1]*i%mod , revFact[i] = power(fact[i], mod-2);

}

ll calc(int n) {
    if(form[n] != -1) return form[n];
    form[n] = 0;
    lp(i, 0, n) form[n] = (form[n] + i*nCk(n, i)%mod)%mod;
    return form[n];
}

int main()
{

    init();
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++divs[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) divs[i] += divs[j];

    clr(form, -1);
    ll ans = 0;
    lp(i, 2, A-2) {
        ll num = calc(divs[i]);
        for(int p:primesFact[i]) if(i/p > 1)
            ans = (ans - num*(i/p)%mod + mod) %mod;
        ans = (ans+num*i%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 6 4 6

 3
 2 4 8

 4
 2 4 6 12
 */


#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 200005 , A = 1000005;
int n,a[N];
ll dp[A],fact[N],revFact[N],form[N];
vi primesFact[A];

ll nCk(ll n,ll k) {
    if(!k || n == k) return 1;
    if(k < 0 || n <= 0 || k > n) return 0;
    return fact[n]*revFact[n-k]%mod*revFact[k]%mod;
}

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

void init() {
    for(int i = 2; i < A ; ++i) if(!sz(primesFact[i]))
        for(int j = i ; j < A ; j += i) primesFact[j].pb(i);

    fact[0] = fact[1] = revFact[0] = revFact[1] = 1;
    lp(i, 2, N-2)
        fact[i] = fact[i-1]*i%mod , revFact[i] = power(fact[i], mod-2);

}

ll calc(ll n) {
    if(form[n] != -1) return form[n];
    form[n] = 0;
    lp(i, 0, n)
        form[n] = (form[n] + i*nCk(n, i)%mod)%mod;
    return form[n];
}

int main()
{

    init();
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++dp[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) dp[i] += dp[j];

    clr(form, -1);
    ll ans = 0;
    lpd(i, A-2, 2) {
        dp[i] = calc(dp[i]);
        for(int j = 2*i ; j < A ; j += i)
            dp[i] = (dp[i] - dp[j] + mod)%mod;

        ans = (ans + i*dp[i]%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 3 4 6

 3
 2 4 8

 4
 2 4 6 12

 3
 2 4 6
 */


#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 200005 , A = 1000005;
int n,a[N],divs[A];
ll fact[N],revFact[N],form[N];
vi primesFact[A];

ll nCk(int n,int k) {
    if(!k || n == k) return 1;
    if(k < 0 || n <= 0 || k > n) return 0;
    return fact[n]*revFact[n-k]%mod*revFact[k]%mod;
}

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

void init() {
    for(int i = 2; i < A ; ++i) if(!sz(primesFact[i]))
        for(int j = i ; j < A ; j += i) primesFact[j].pb(i);

    fact[0] = fact[1] = revFact[0] = revFact[1] = 1;
    lp(i, 2, N-2)
        fact[i] = fact[i-1]*i%mod , revFact[i] = power(fact[i], mod-2);

}

ll calc(int n) {
    if(form[n] != -1) return form[n];
    form[n] = 0;
    lp(i, 0, n) form[n] = (form[n] + i*nCk(n, i)%mod)%mod;
    return form[n];
}

int main()
{

    init();
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++divs[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) divs[i] += divs[j];

    clr(form, -1);
    ll ans = 0;
    lp(i, 2, A-2) {
        ll num = calc(divs[i]);
        for(int p:primesFact[i]) if(i/p > 1 && i%p == 0)
            ans = (ans - num*(i/p)%mod + mod) %mod;

        lp(j, 0, sz(primesFact[i])-1) lp(k, j+1, sz(primesFact[i])-1) {
            int x = i/primesFact[i][j] , y = i/primesFact[i][k];
            int g = __gcd(x,y);
            if(g != 1) ans = (ans+num*g%mod)%mod;
        }

        ans = (ans+num*i%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 6 4 6

 3
 2 4 8

 4
 2 4 6 12

 3
 2 4 6
 */


#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 2005 , A = 1005;
int n,a[N];
ll dp[A],fact[N],revFact[N],form[N];
vi primesFact[A];

ll nCk(ll n,ll k) {
    if(!k || n == k) return 1;
    if(k < 0 || n <= 0 || k > n) return 0;
    return fact[n]*revFact[n-k]%mod*revFact[k]%mod;
}

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

void init() {
    for(int i = 2; i < A ; ++i) if(!sz(primesFact[i]))
        for(int j = i ; j < A ; j += i) primesFact[j].pb(i);

    fact[0] = fact[1] = revFact[0] = revFact[1] = 1;
    lp(i, 2, N-2)
        fact[i] = fact[i-1]*i%mod , revFact[i] = power(fact[i], mod-2);

}

ll calc(ll n) {
    if(form[n] != -1) return form[n];
    form[n] = 0;
    lp(i, 0, n)
        form[n] = (form[n] + i*nCk(n, i)%mod)%mod;
    return form[n];
}

int main()
{

    init();
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++dp[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) dp[i] += dp[j];

    clr(form, -1);
    ll ans = 0;
    lpd(i, A-2, 2) {
        dp[i] = calc(dp[i]);
        for(int j = 2*i ; j < A ; j += i)
            dp[i] = (dp[i] - dp[j] + mod)%mod;

        ans = (ans + i*dp[i]%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 3 4 6

 3
 2 4 8

 4
 2 4 6 12

 3
 2 4 6
 */


#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 200005 , A = 1000005;
int n,a[N],divs[A];
ll fact[N],revFact[N],form[N];
vi primesFact[A];

ll nCk(int n,int k) {
    if(!k || n == k) return 1;
    if(k < 0 || n <= 0 || k > n) return 0;
    return fact[n]*revFact[n-k]%mod*revFact[k]%mod;
}

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

void init() {
    for(int i = 2; i < A ; ++i) if(!sz(primesFact[i]))
        for(int j = i ; j < A ; j += i) primesFact[j].pb(i);

    fact[0] = fact[1] = revFact[0] = revFact[1] = 1;
    lp(i, 2, N-2)
        fact[i] = fact[i-1]*i%mod , revFact[i] = power(fact[i], mod-2);

}

ll calc(int n) {
    if(form[n] != -1) return form[n];
    form[n] = 0;
    lp(i, 0, n) form[n] = (form[n] + i*nCk(n, i)%mod)%mod;
    return form[n];
}

int main()
{

    init();
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++divs[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) divs[i] += divs[j];

    clr(form, -1);
    ll ans = 0;
    lp(i, 2, A-2) {
        ll num = calc(divs[i]);
        for(int p:primesFact[i]) if(i/p > 1)
            ans = (ans - num*(i/p)%mod + mod) %mod;
        ans = (ans+num*i%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 6 4 6

 3
 2 4 8

 4
 2 4 6 12
 */


#include<set>
#include <unordered_set>
#include <unordered_map>
#include<map>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <string.h>
#include <strings.h>

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define readll(x) scanf("%I64d",&x)
#define mod 1000000007
#define eps 1e-6
#define infi 1000000000
#define infll 1000000000000000000ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef unordered_set<int> usi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef unordered_map<ll,ll> umll;

const int N = 205 , A = 1005;
int n,a[N],divs[A];
ll fact[N],revFact[N],form[N];
vi primesFact[A];

ll nCk(int n,int k) {
    if(!k || n == k) return 1;
    if(k < 0 || n <= 0 || k > n) return 0;
    return fact[n]*revFact[n-k]%mod*revFact[k]%mod;
}

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}

void init() {
    for(int i = 2; i < A ; ++i) if(!sz(primesFact[i]))
        for(int j = i ; j < A ; j += i) primesFact[j].pb(i);

    fact[0] = fact[1] = revFact[0] = revFact[1] = 1;
    lp(i, 2, N-2)
        fact[i] = fact[i-1]*i%mod , revFact[i] = power(fact[i], mod-2);

}

ll calc(int n) {
    if(form[n] != -1) return form[n];
    form[n] = 0;
    lp(i, 0, n) form[n] = (form[n] + i*nCk(n, i)%mod)%mod;
    return form[n];
}

int main()
{

    init();
    scanf("%d",&n);
    lp(i, 1, n) scanf("%d",&a[i]) , ++divs[a[i]];

    lp(i, 2, A-2)
        for(int j = 2*i ; j < A ; j += i) divs[i] += divs[j];

    clr(form, -1);
    ll ans = 0;
    lp(i, 2, A-2) {
        ll num = calc(divs[i]);
        for(int p:primesFact[i]) if(i/p > 1 && i%p == 0)
            ans = (ans - num*(i/p)%mod + mod) %mod;

        lp(j, 0, sz(primesFact[i])-1) lp(k, j+1, sz(primesFact[i])-1) {
            int x = i/primesFact[i][j] , y = i/primesFact[i][k];
            int g = __gcd(x,y);
            if(g != 1) ans = (ans+num*g%mod)%mod;
        }

        ans = (ans+num*i%mod)%mod;
    }

    printf("%lld\n",ans);
    return 0;
}

/*
 4
 2 6 4 6

 3
 2 4 8

 4
 2 4 6 12

 3
 2 4 6
 */


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ans[1000005],cnt[1000005];
ll power[200005];
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    map <ll,ll> freq;
    ll maxi = LONG_LONG_MIN;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
        for(ll j=2;j<=sqrt(a[i]);j++)
        {
            if(a[i]%j==0)
            {
                cnt[j]++;
                if(j!=a[i]/j)
                {
                    cnt[a[i]/j]++;
                }
            }
        }
        maxi = max(maxi,a[i]);
    }
    power[0]= 1;
    for(ll i=1;i<=200000;i++)
    {
        power[i] = power[i-1]*2;
        power[i] %= 1000000007;
    }
    ll res = 0;
    for(ll i=maxi;i>=2;i--)
    {
        if(cnt[i]>=1)
        {
            ans[i] = cnt[i]*power[cnt[i]-1];
            ans[i] = ans[i]%1000000007;
            if(i<=maxi/2)
            {
                for(ll j=2*i;j<=maxi;j+=i)
                {
                    ans[i] -= ans[j];
                    if(ans[i]<0)
                    {
                        ans[i]+= 1000000007;
                    }
                }
            }
            res+= i*ans[i];
            res = res%1000000007;
        }
    }
    cout<<res<<"\n";
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

int pw[MAXA];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < MAXA ; i++ ) {
        pw[i] = (pw[i - 1] * 2) % MOD;
    }

    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        cnt[a[i]]++;
        for ( int j = 2 ; j < a[i] ; j++ ) {
            if ( a[i] % j == 0 ) {
                cnt[j] ++;
            }
        }
    }

    for ( int i = max_a ; i >= 2 ; i-- ) {
        if ( cnt[i] ) {
            // printf("cnt[%d] = %d\n", i, cnt[i]);
            dp[i] = 1LL * cnt[i] * pw[cnt[i] - 1] % MOD;
            // printf("dp[%d] = %d\n", i, dp[i]);
            for ( int j = i * 2 ; j <= max_a ; j += i ) {
                dp[i] = (dp[i] - dp[j] + MOD) % MOD;
            }
            res = ( res + 1LL * i * dp[i] % MOD ) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 2005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

long long pw(int n, int p) {
    if ( p < 0 ) return 0;
    long long res = 1, x = n;
    while ( p ) {
        if ( p & 1 ) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p >>= 1;
    }
    return res % MOD;
}

void solve() {
    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        dp[a[i]] += 1;
        for ( auto r : pr ) {
            if ( r >= a[i] ) break;
            if ( a[i] % r == 0 ) {
                dp[r] += dp[a[i]];
            }
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        dp[i] = 1LL * dp[i] * pw(2, dp[i] - 1) % MOD;
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        for ( int j = 2 ; 1LL * i * j <= 1LL * max_a ; j++ ) {
            dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        res = (res + 1LL * i * dp[i] % MOD) % MOD;
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

long long pw(int n, int p) {
    if ( p < 0 ) return 0;
    long long res = 1, x = n;
    while ( p ) {
        if ( p & 1 ) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p >>= 1;
    }
    return res % MOD;
}

void solve() {
    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        dp[a[i]] += 1;
        for ( auto r : pr ) {
            if ( r >= a[i] ) break;
            if ( a[i] % r == 0 ) {
                dp[r] += dp[a[i]];
            }
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            // printf("dp[%d] = %d\n", i, dp[i]);
            dp[i] = 1LL * dp[i] * pw(2, dp[i] - 1) % MOD;
            // printf("# dp[%d] = %d\n", i, dp[i]);
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] )
        for ( int j = 2 ; 1LL * i * j <= 1LL * max_a ; j++ ) {
            if ( dp[i*j] > 0)
            dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            //printf("R dp[%d] = %d\n", i, dp[i]);
        res = (res + 1LL * i * dp[i] % MOD) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

int pw[MAXA];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < MAXA ; i++ ) {
        pw[i] = (pw[i - 1] * 2) % MOD;
    }

    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        cnt[a[i]]++;
        for ( int j = 2 ; j * j <= a[i] ; j++ ) {
            if ( a[i] % j == 0 ) {
                cnt[j] ++;
                if ( a[i]/j != j ) cnt[a[i]/j]++;
            }
        }
    }

    for ( int i = max_a ; i >= 2 ; i-- ) {
        if ( cnt[i] ) {
            // printf("cnt[%d] = %d\n", i, cnt[i]);
            dp[i] = 1LL * cnt[i] * pw[cnt[i] - 1] % MOD;
            // printf("dp[%d] = %d\n", i, dp[i]);
            for ( int j = i * 2 ; j <= max_a ; j += i ) {
                if ( dp[j] )
                dp[i] = (dp[i] - dp[j] + MOD) % MOD;
            }
            res = ( res + 1LL * i * dp[i] % MOD ) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    scanf("%d", &n);
    for ( int i = 0 ; i < n ; i++ ) {
        scanf("%d", &a[i]);
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

int pw[MAXA];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < MAXA ; i++ ) {
        pw[i] = (pw[i - 1] * 2) % MOD;
    }

    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        dp[a[i]] += 1;
        for ( int j = 2 ; j < a[i] ; j++ ) {
            if ( a[i] % j == 0 ) {
                dp[j] ++;
            }
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            // printf("dp[%d] = %d\n", i, dp[i]);
            dp[i] = 1LL * dp[i] * pw[dp[i] - 1] % MOD;
            // printf("# dp[%d] = %d\n", i, dp[i]);
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] )
        for ( int j = 2 ; 1LL * i * j <= 1LL * max_a ; j++ ) {
            if ( dp[i*j] > 0)
            dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            //printf("R dp[%d] = %d\n", i, dp[i]);
        res = (res + 1LL * i * dp[i] % MOD) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int pw[MAXA];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < MAXA ; i++ ) pw[i] = (pw[i - 1] * 2) % MOD;

    long long res = 0;

    for ( int i = MAXA - 1 ; i >= 2 ; i-- ) {
        int x = 0;
        for ( int j = i ; j < MAXA ; j+=i ) x += cnt[j];
        if ( x ) {
            dp[i] = 1LL * x * pw[x - 1] % MOD;
            for ( int j = i * 2 ; j < MAXA ; j += i ) {
                if ( dp[j] )
                dp[i] = (dp[i] - dp[j] + MOD) % MOD;
            }
            res = ( res + 1LL * i * dp[i] % MOD ) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    scanf("%d", &n);
    for ( int i = 0, a ; i < n ; i++ ) {
        scanf("%d", &a);
        cnt[a]++;
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

// long long pw(int n, int p) {
//     if ( p < 0 ) return 0;
//     long long res = 1, x = n;
//     while ( p ) {
//         if ( p & 1 ) res = (res * x) % MOD;
//         x = (x * x) % MOD;
//         p >>= 1;
//     }
//     return res % MOD;
// }

int pw[MAXA*5];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < 5*MAXA ; i++ ) {
        pw[i] = (pw[i - 1] * 2) % MOD;
    }

    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        dp[a[i]] += 1;
        for ( auto r : pr ) {
            if ( r >= a[i] ) break;
            if ( a[i] % r == 0 ) {
                dp[r] += dp[a[i]];
            }
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            // printf("dp[%d] = %d\n", i, dp[i]);
            dp[i] = 1LL * dp[i] * pw[dp[i] - 1] % MOD;
            // printf("# dp[%d] = %d\n", i, dp[i]);
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] )
        for ( int j = 2 ; 1LL * i * j <= 1LL * max_a ; j++ ) {
            if ( dp[i*j] > 0)
            dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            //printf("R dp[%d] = %d\n", i, dp[i]);
        res = (res + 1LL * i * dp[i] % MOD) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

int pw[MAXA*5];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < 5*MAXA ; i++ ) {
        pw[i] = (pw[i - 1] * 2) % MOD;
    }

    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        dp[a[i]] += 1;
        for ( int j = 2 ; j < a[i] ; j++ ) {
            if ( a[i] % j == 0 ) {
                dp[j] += dp[a[i]];
            }
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            // printf("dp[%d] = %d\n", i, dp[i]);
            dp[i] = 1LL * dp[i] * pw[dp[i] - 1] % MOD;
            // printf("# dp[%d] = %d\n", i, dp[i]);
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] )
        for ( int j = 2 ; 1LL * i * j <= 1LL * max_a ; j++ ) {
            if ( dp[i*j] > 0)
            dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            //printf("R dp[%d] = %d\n", i, dp[i]);
        res = (res + 1LL * i * dp[i] % MOD) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

long long pw(int n, int p) {
    if ( p < 0 ) return 0;
    long long res = 1, x = n;
    while ( p ) {
        if ( p & 1 ) res = (res * x) % MOD;
        x = (x * x) % MOD;
        p >>= 1;
    }
    return res % MOD;
}

void solve() {
    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        dp[a[i]] += 1;
        for ( auto r : pr ) {
            if ( r >= a[i] ) break;
            if ( a[i] % r == 0 ) {
                dp[r] += dp[a[i]];
            }
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            // printf("dp[%d] = %d\n", i, dp[i]);
            dp[i] = 1LL * dp[i] * pw(2, dp[i] - 1) % MOD;
            // printf("# dp[%d] = %d\n", i, dp[i]);
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] )
        for ( int j = 2 ; 1LL * i * j <= 1LL * max_a ; j++ ) {
            dp[i] = (dp[i] - dp[i * j] + MOD) % MOD;
        }
    }

    for ( int i = 2 ; i <= max_a ; i++ ) {
        if ( dp[i] ) {
            //printf("R dp[%d] = %d\n", i, dp[i]);
        res = (res + 1LL * i * dp[i] % MOD) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;
const int MAXN = 200005;
const int MAXA = 1000005;

int n;
int dp[MAXA] = {0};
int cnt[MAXA] = {0};
int p[MAXA];
vector<int> pr;
int a[MAXN];

void init() {
    for ( int i = 2 ; i < MAXA ; i++ )
        if (!p[i]) for ( long long j = 1LL*i*i ; j < MAXA ; j += i ) p[j] = 1;
    for ( int i = 2 ; i < MAXA ; i++) if ( p[i] == 0 )
        pr.push_back(i);
}

int pw[MAXA];

void solve() {

    pw[0] = 1;
    for ( int i = 1 ; i < MAXA ; i++ ) {
        pw[i] = (pw[i - 1] * 2) % MOD;
    }

    int max_a = 0;
    long long res = 0;
    for ( int i = 0 ; i < n ; i++ ) {
        max_a = max(max_a, a[i]);
        if ( a[i] == 1 ) continue;
        cnt[a[i]]++;
        for ( int j = 2 ; j < a[i] ; j++ ) {
            if ( a[i] % j == 0 ) {
                cnt[j] ++;
            }
        }
    }

    for ( int i = max_a ; i >= 2 ; i-- ) {
        if ( cnt[i] ) {
            // printf("cnt[%d] = %d\n", i, cnt[i]);
            dp[i] = cnt[i] * pw[cnt[i] - 1] % MOD;
            // printf("dp[%d] = %d\n", i, dp[i]);
            for ( int j = i * 2 ; j <= max_a ; j += i ) {
                dp[i] = (dp[i] - dp[j] + MOD) % MOD;
            }
            res = ( res + i * dp[i] ) % MOD;
        }
    }

    cout << res % MOD << endl;

}

int main () {

    init();

    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }

    solve();

    return 0;
}


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX],pw[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
int main(){
	pw[0]=1LL;
	rep(i,1,MAX){
		pw[i]=2LL*pw[i-1];
		chk(pw[i]);
	}
	ll n;
	ll res=0LL,MX=0LL;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	rep(j,0LL,n){
		ll x;
		cin>>x;
		MX=max(x,MX);
		ll rt=sqrt((double)x)+1LL;
		rep(i,1LL,rt){
			if(x%i==0LL){
				++cnt[i];
				chk(cnt[i]);
				if((x/i)!=i){
					++cnt[x/i];
					chk(cnt[x/i]);
				}
			}
		}
	}
	for(ll i=MX;i>=2LL;i=i-1LL){
		if(cnt[i]!=0LL){
		ans[i]=cnt[i]*pw[cnt[i]-1LL];
		ll j=i*2LL;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0LL;
	for(ll i=2LL;i<=MX;i+=1LL){
		tmp=i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	cout<<res<<"\n";
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
ll expo(ll a,ll b){
	ll res=1LL;
	chk(a);
	chk(b);
	while(b>0){
		if(b&1LL)
			res*=a;
		chk(res);
		b >>=1LL;
		a*=a;
		chk(a);
	}
	return res;
}
int main(){
	ll n;
	ll res=0LL,MX=0LL;
	scanf("%lld",&n);
	rep(j,0,n){
		ll x;
		scanf("%lld",&x);
		MX=max(x,MX);
		ll rt=sqrt(x)+1LL;
		rep(i,1LL,rt){
			if(x%i==0LL){
				++cnt[i];
				chk(cnt[i]);
				if(x/i!=i){
					++cnt[x/i];
					chk(cnt[x/i]);
				}
			}
		}
	}
	for(ll i=MX;i>=2LL;--i){
		if(cnt[i]!=0LL){
		ans[i]=cnt[i]*expo(2LL,cnt[i]-1);
		ll j=i<<1LL;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0;
	for(ll i=2LL;i<=MX;++i){
		tmp=i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	printf("%lld\n",res);
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
ll expo(ll a,ll b){
	ll res=1LL;
	chk(a);
	chk(b);
	while(b>0LL){
		if(b%2LL==1LL)
			res*=a;
		chk(res);
		b >>=1LL;
		a*=a;
		chk(a);
	}
	return res;
}
int main(){
	ll n;
	ll res=0LL,MX=0LL;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	rep(j,0,n){
		ll x;
		cin>>x;
		MX=max(x,MX);
		ll rt=sqrt((double)x)+1LL;
		rep(i,1LL,rt){
			if(x%i==0LL){
				++cnt[i];
				chk(cnt[i]);
				if(x/i!=i){
					++cnt[x/i];
					chk(cnt[x/i]);
				}
			}
		}
	}
	for(ll i=MX;i>=2LL;--i){
		if(cnt[i]!=0LL){
		ans[i]=cnt[i]*expo(2LL,cnt[i]-1);
		ll j=i<<1LL;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0LL;
	for(ll i=2LL;i<=MX;++i){
		tmp=i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	cout<<res<<"\n";
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX],pw[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	pw[0]=1LL;
	rep(i,1,MAX){
		pw[i]=2LL*pw[i-1];
		chk(pw[i]);
	}
	int n,MX=0;
	ll res=0LL;
	cin>>n;
	rep(j,0,n){
		int x,rt;
		cin>>x;
		MX=max(x,MX);
	//	++cnt[x];
		rt=sqrt(x)+1;
		rep(i,1,rt){
			if(x%i==0){
				++cnt[i];
				chk(cnt[i]);
				if(x/i!=i){
					++cnt[x/i];
					chk(cnt[x/i]);
				}
			}
		}
	}
	/*for(int i=2;i<=MX;++i){
		for(int j=i<<1;j<=MX;j+=i){
			cnt[i]+=cnt[j];
		}
	}*/
	for(int i=MX;i>=2;--i){
		if(cnt[i]!=0){
		ans[i]=cnt[i]*pw[cnt[i]-1];
		chk(ans[i]);
		int j=i<<1;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0LL;
	for(int i=2;i<=MX;++i){
		tmp=1LL*i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	cout<<res<<"\n";
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX],pw[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	pw[0]=1LL;
	rep(i,1,MAX){
		pw[i]=2LL*pw[i-1];
		chk(pw[i]);
	}
	int n,MX=0;
	ll res=0LL;
	cin>>n;
	rep(j,0,n){
		int x;
		cin>>x;
		MX=max(x,MX);
		++cnt[x];
	}
	for(int i=2;i<=MX;++i){
		for(int j=i<<1;j<=MX;j+=i){
			cnt[i]+=cnt[j];
		}
	}
	for(int i=MX;i>=2;--i){
		if(cnt[i]!=0){
		ans[i]=cnt[i]*pw[cnt[i]-1];
		chk(ans[i]);
		int j=i<<1;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0LL;
	for(int i=2;i<=MX;++i){
		tmp=1LL*i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	cout<<res<<"\n";
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
ll expo(ll a,ll b){
	ll res=1LL;
	chk(a);
	chk(b);
	while(b>0){
		if(b&1LL)
			res*=a;
		chk(res);
		b >>=1LL;
		a*=a;
		chk(a);
	}
	return res;
}
int main(){
	ll n;
	ll res=0LL,MX=0LL;
	scanf("%lld",&n);
	rep(j,0,n){
		ll x;
		scanf("%lld",&x);
		MX=max(x,MX);
		ll rt=sqrt(x)+1LL;
		rep(i,1LL,rt){
			if(x%i==0LL){
				++cnt[i];
				chk(cnt[i]);
				if(x/i!=i){
					++cnt[x/i];
					chk(cnt[x/i]);
				}
			}
		}
	}
	for(ll i=MX;i>=2LL;--i){
		if(cnt[i]!=0LL){
		ans[i]=cnt[i]*expo(2LL,cnt[i]-1);
		ll j=i<<1LL;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0LL;
	for(ll i=2LL;i<=MX;++i){
		tmp=i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	printf("%lld\n",res);
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


/** Source code by WDragon **/
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007LL
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define all(v) (v).begin(),(v).end()
#define FF first
#define SS second
using namespace std;
//ll dx[]={1,0,0,-1},dy[]={0,1,-1,0};
ll cnt[MAX],ans[MAX];
void chk(ll &num){
	if(num<0)
		num+=MOD;
	if(num>=MOD)
		num%=MOD;
}
ll expo(ll a,ll b){
	ll res=1LL;
	chk(a);
	chk(b);
	while(b>0LL){
		if(b%2LL==1LL)
			res*=a;
		chk(res);
		b >>=1LL;
		a*=a;
		chk(a);
	}
	return res;
}
int main(){
	ll n;
	ll res=0LL,MX=0LL;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	rep(j,0,n){
		ll x;
		cin>>x;
		MX=max(x,MX);
		ll rt=sqrt((double)x)+1LL;
		rep(i,1LL,rt){
			if(x%i==0LL){
				++cnt[i];
				chk(cnt[i]);
				if(x/i!=i){
					++cnt[x/i];
					chk(cnt[x/i]);
				}
			}
		}
	}
	for(ll i=MX;i>=2LL;--i){
		if(cnt[i]!=0LL){
		ans[i]=cnt[i]*expo(2LL,cnt[i]-1);
		ll j=i*2LL;
		while(j<=MX){
			ans[i]-=ans[j];
			chk(ans[i]);
			j+=i;
		}
	}
	}
	ll tmp=0LL;
	for(ll i=2LL;i<=MX;++i){
		tmp=i*ans[i];
		chk(tmp);
		res+=tmp;
		chk(res);
	}
	cout<<res<<"\n";
return 0;
}
/** Somewhere deep in these lines strings are getting mutated.
	Those may become lost...but you have won. **/


#include "cstdio"
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll sum[1000010];
ll q[100010];
int main(){
    ll Sum=0;
    q[0]=1;
    int n; scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a,j; scanf("%d",&a);
        for(j=1;j*j<a;j++)
            if(a%j==0) sum[j]++,sum[a/j]++;
        if(j*j==a) sum[j]++;
        q[i] = (q[i-1]*2%mod);

    }
    for(ll i=1000000;i>=2;i--)
        if(sum[i]){
            sum[i] =(sum[i]%mod*q[sum[i]-1]%mod)%mod;
            for(ll j=i+i;j<=1000000;j+=i)
                sum[i] =((sum[i]-sum[j])%mod+mod)%mod;
            Sum =(Sum + sum[i]*i%mod)%mod;
        }
    printf("%lld\n",Sum);
    return 0;
}


#include "cstdio"
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll sum[1000010];
ll qpow(ll base,ll m){
    ll ans=1;
    while(m){
        if(m&1) ans = ans * base % mod;
        base = base * base % mod;
        m>>=1;
    }
    return ans;
}
int main(){
    ll Sum=0;
    int n; scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a,j; scanf("%d",&a);
        for(j=1;j*j<a;j++)
            if(a%j==0) sum[j]++,sum[a/j]++;
        if(j*j==a) sum[j]++;

    }
    for(ll i=1000000;i>=2;i--)
        if(sum[i]){
            Sum =(Sum + i*sum[i]%mod*qpow(2,sum[i]-1)%mod)%mod;
            for(ll j=i+i;j<=1000000;j+=i){
                if(sum[j])
                Sum =((Sum - i*sum[j]%mod*qpow(2,sum[j]-1)%mod)%mod +mod)%mod;
            }
        }
    printf("%lld\n",Sum);
    return 0;
}


#include "cstdio"
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll sum[1000010];
ll qpow(ll base,ll m){
    ll ans=1;
    while(m){
        if(m&1) ans = ans * base % mod;
        base = base * base % mod;
        m>>=1;
    }
    return ans;
}
int main(){
    ll Sum=0;
    int n; scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a,j; scanf("%d",&a);
        for(j=1;j*j<a;j++)
            if(a%j==0) sum[j]++,sum[a/j]++;
        if(j*j==a) sum[j]++;

    }
    for(ll i=1000000;i>=2;i--)
        if(sum[i]){
            sum[i] =(sum[i]%mod*qpow(2,sum[i]-1)%mod)%mod;
            for(ll j=i+i;j<=1000000;j+=i)
                sum[i] =((sum[i]-sum[j])%mod+mod)%mod;
            Sum =(Sum + sum[i]*i%mod)%mod;
        }
    printf("%lld\n",Sum);
    return 0;
}


#include "cstdio"
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll sum[1000010];
ll qpow(ll base,ll m){
    ll ans=1;
    while(m){
        if(m&1) ans = ans * base % mod;
        base = base * base % mod;
        m>>=1;
    }
    return ans;
}
int main(){
//    ll t=0;
//    for(int i=1;i<=1000000;i++)
//        for(int j=i+i;j<=1000000;j+=i) t++;
//    printf("%lld\n",t);
    ll Sum=0;
    int n; scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a,j; scanf("%d",&a);
        for(j=1;j*j<a;j++)
            if(a%j==0) sum[j]++,sum[a/j]++;
        if(j*j==a) sum[j]++;

    }
    for(ll i=2;i<=1000000;i++)
        if(sum[i]){
            Sum =(Sum + i*sum[i]%mod*qpow(2,sum[i]-1)%mod)%mod;
            for(ll j=i+i;j<=1000000;j+=i){
                if(sum[j])
                Sum =((Sum - i*sum[j]%mod*qpow(2,sum[j]-1)%mod)%mod +mod)%mod;
            }
//            printf("%lld %lld %lld\n",i,sum[i],Sum);
        }
    printf("%lld\n",Sum);
    return 0;
}


#include "cstdio"
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll sum[1000010];
ll q[200010];
int main(){
    ll Sum=0;
    q[0]=1;
    int n; scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int a,j; scanf("%d",&a);
        for(j=1;j*j<a;j++)
            if(a%j==0) sum[j]++,sum[a/j]++;
        if(j*j==a) sum[j]++;
        q[i] = (q[i-1]*2%mod);

    }
    for(ll i=1000000;i>=2;i--)
        if(sum[i]){
            sum[i] =(sum[i]%mod*q[sum[i]-1]%mod)%mod;
            for(ll j=i+i;j<=1000000;j+=i)
                sum[i] =((sum[i]-sum[j])%mod+mod)%mod;
            Sum =(Sum + sum[i]*i%mod)%mod;
        }
    printf("%lld\n",Sum);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 1000005
using namespace std;
ll kq,n,tmp,ans[N],mu[N],base=1e9+7,f[N],a,d[N];
int main()
{
    //freopen("t.inp","r",stdin);
    //freopen("t.out","w",stdout);
    mu[0]=1;
    fort(i,1,1e6) mu[i]=mu[i-1]*2%base;
    cin>>n;
    fort(i,1,n){
        cin>>a;
        d[a]++;
    }
    ford(i,1e6,2){
        f[i]=d[i]%base;
        tmp=0;
        fort(j,2,1e6){
            if (i*j>1e6) break;
            f[i]+=f[i*j];
            f[i]%=base;
            tmp+=ans[i*j];
            tmp%=base;
        }
        if (f[i]>0){
            ans[i]=(f[i]*mu[f[i]-1]-tmp+base*base)%base;
            kq+=ans[i]*i;
            kq%=base;
        }
    }
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 1000005
using namespace std;
ll kq,n,tmp,ans[N],mu[N],base=1e9+7,f[N],a,d[N];
int main()
{
    //freopen("t.inp","r",stdin);
    //freopen("t.out","w",stdout);
    mu[0]=1;
    fort(i,1,1e6) mu[i]=mu[i-1]*2%base;
    cin>>n;
    fort(i,1,n){
        cin>>a;
        d[a]++;
    }
    ford(i,1e6,2){
        f[i]=d[i]%base;
        tmp=0;
        fort(j,2,1e6){
            if (i*j>1e6) break;
            f[i]+=f[i*j];
            f[i]%=base;
            tmp+=ans[i*j];
            tmp%=base;
        }
        if (f[i]>0){
            ans[i]=(f[i]*mu[f[i]-1]-tmp+base)%base;
            kq+=ans[i]*i;
            kq%=base;
        }
    }
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 5000005
using namespace std;
ll kq,n,tmp,ans[N],mu[N],base=1e9+7,f[N],a;
int main()
{
    //freopen("t.inp","r",stdin);
    //freopen("t.out","w",stdout);
    mu[0]=1;
    fort(i,1,1e6) mu[i]=mu[i-1]*2%base;
    cin>>n;
    fort(i,1,n){
        cin>>a;
        f[a]++;
    }
    ford(i,1e6,2){
        tmp=f[i];
        fort(j,2,1e6){
            if (i*j>1e6) break;
            tmp+=f[i*j];
        }
        if (tmp){
            ans[i]=tmp*mu[tmp-1]%base;
            fort(j,2,1e6){
                if (i*j>1e6) break;
                ans[i]=(ans[i]-ans[i*j]+base)%base;
            }
            kq+=ans[i]*i;
            kq%=base;
        }
    }
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 2000005
using namespace std;
ll kq,n,tmp,ans[N],mu[N],base=1e9+7,f[N],a,d[N];
int main()
{
    //freopen("t.inp","r",stdin);
    //freopen("t.out","w",stdout);
    mu[0]=1;
    fort(i,1,1e6) mu[i]=mu[i-1]*2%base;
    cin>>n;
    fort(i,1,n){
        cin>>a;
        d[a]++;
    }
    ford(i,1e6,2){
        f[i]=d[i]%base;
        tmp=0;
        fort(j,2,1e6){
            if (i*j>1e6) break;
            f[i]+=f[i*j];
            f[i]%=base;
            tmp+=ans[i*j];
            tmp%=base;
        }
        if (f[i]>0){
            ans[i]=(f[i]*mu[f[i]-1]-tmp+base)%base;
            kq+=ans[i]*i;
            kq%=base;
        }
    }
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 1000005
using namespace std;
ll kq,n,tmp,ans[N],mu[N],base=1e9+7,f[N],a,d[N];
int main()
{
    //freopen("t.inp","r",stdin);
    //freopen("t.out","w",stdout);
    mu[0]=1;
    fort(i,1,1e6) mu[i]=mu[i-1]*2%base;
    cin>>n;
    fort(i,1,n){
        cin>>a;
        d[a]++;
    }
    ford(i,1e6,2){
        f[i]=d[i]%base;
        tmp=0;
        fort(j,2,1e6){
            if (i*j>1e6) break;
            f[i]+=f[i*j];
            f[i]%=base;
            tmp+=ans[i*j];
            tmp%=base;
        }
        if (f[i]>0&&tmp>0){
            ans[i]=(f[i]*mu[f[i]-1]-tmp+base*base)%base;
            kq+=ans[i]*i;
            kq%=base;
        }
    }
    cout<<kq;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 1000005
using namespace std;
ll kq,n,tmp,ans[N],mu[N],base=1e9+7,f[N],a,d[N];
int main()
{
    //freopen("t.inp","r",stdin);
    //freopen("t.out","w",stdout);
    mu[0]=1;
    fort(i,1,1e6) mu[i]=mu[i-1]*2%base;
    cin>>n;
    fort(i,1,n){
        cin>>a;
        d[a]++;
    }
    ford(i,1e6,2){
        f[i]=d[i];
        tmp=0;
        fort(j,2,1e6){
            if (i*j>1e6) break;
            f[i]+=f[i*j];
            tmp+=ans[i*j];
        }
        if (f[i]>0){
            ans[i]=(f[i]*mu[f[i]-1]-tmp+base)%base;
            kq+=ans[i]*i;
            kq%=base;
        }
    }
    cout<<kq;
    return 0;
}


#include<bits/stdc++.h>

#define fin() freopen("input.txt","r",stdin)
#define fout() freopen("out.txt","w",stdout)
#define ss(dp,n) memset (dp,n, sizeof (dp))
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define MOD 1000000007
#define N 1000005
#define LN 20
#define inf 1e18+5
#define fast_io  ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll n, m, a[N];
ll bexpo (ll x, ll n, ll m)
{
	ll r = 1;
	while (n > 0)
	{
		if (n % 2) r = (r * x) % m;
		x = (x * x) % m;
		n = n / 2;
	}
	return r;
}
ll sum[N];
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	cin >> n;
	for (ll i = 2; i < N; i++)
	{
		for (ll j = 2 * i; j < N; j += i)
			sum[j] += i, sum[j] %= MOD;
	}
	for (ll i = 1; i <= n; i++)
	{
		ll d;
		cin >> d;
		a[d]++;
	}
	ll ans = 0;
	for (ll i = 2; i < N; i++)
	{
		ll temp = 0;
		for (ll j = i; j < N; j += i)
			temp += a[j];
		temp = (temp * bexpo (2, temp - 1, MOD)) % MOD;
		ll pro = (i - sum[i]) % MOD;
		pro = (pro + MOD) % MOD;
		temp = (temp * pro) % MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

#define fin() freopen("input.txt","r",stdin)
#define fout() freopen("out.txt","w",stdout)
#define ss(dp,n) memset (dp,n, sizeof (dp))
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define MOD 1000000007
#define N 1000005
#define LN 20
#define inf 1e18+5
#define fast_io  ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll n, m, a[N];
ll bexpo (ll x, ll n, ll m)
{
	ll r = 1;
	while (n > 0)
	{
		if (n % 2) r = (r * x) % m;
		x = (x * x) % m;
		n = n / 2;
	}
	return r;
}
ll sum[N];
ll mp[N];
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	cin >> n;
	for (ll i = 2; i < N; i++)
	{
		for (ll j = 2 * i; j < N; j += i)
			sum[j] += i, sum[j] %= MOD;
	}
	for (ll i = 1; i < N; i++) mp[i] = i;
	for (ll i = 2; i < N; i++)
	{
		if (mp[i] == i)
			for (ll j = i * i; j < N; j += i)
				mp[j] = i;
	}
	for (ll i = 1; i <= n; i++)
	{
		ll d;
		cin >> d;
		a[d]++;
	}
	ll ans = 0;
	for (ll i = 2; i < N; i++)
	{
		ll temp = 0;
		for (ll j = i; j < N; j += i)
			temp += a[j];
		temp = (temp * bexpo (2, temp - 1, MOD)) % MOD;
		ll pro = (i - sum[i] + mp[i] * sum[i / mp[i]]) % MOD;
		pro = (pro + MOD) % MOD;
		temp = (temp * pro) % MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

#define fin() freopen("input.txt","r",stdin)
#define fout() freopen("out.txt","w",stdout)
#define ss(dp,n) memset (dp,n, sizeof (dp))
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define MOD 1000000007
#define N 1000005
#define LN 20
#define inf 1e18+5
#define fast_io  ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll n, m, a[N];
ll bexpo (ll x, ll n, ll m)
{
	ll r = 1;
	while (n > 0)
	{
		if (n % 2) r = (r * x) % m;
		x = (x * x) % m;
		n = n / 2;
	}
	return r;
}
ll ans[N];
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	cin >> n;
	for (ll i = 1; i <= n; i++)
	{
		ll d;
		cin >> d;
		a[d]++;
	}
	ll ok = 0;
	for (ll i = 2; i < 10; i++)
	{
		ll temp = 0;
		for (ll j = i; j < 10; j += i)
			temp += a[j];
		temp = (temp * bexpo (2, temp - 1, MOD)) % MOD;
		ans[i] = temp;
	}
	for (ll i = N - 1; i > 1; i--)
	{
		for (ll j = 2 * i; j < N; j += i)
		{
			ans[i] -= ans[j];
			ans[i] %= MOD;
			ans[i] += MOD;
			ans[i] %= MOD;
		}
		ok = (ok + (i * ans[i]) % MOD) % MOD;
	}
	cout << ok;
	return 0;
}


#include<bits/stdc++.h>

#define fin() freopen("input.txt","r",stdin)
#define fout() freopen("out.txt","w",stdout)
#define ss(dp,n) memset (dp,n, sizeof (dp))
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define MOD 1000000007
#define N 1000005
#define LN 20
#define inf 1e18+5
#define fast_io  ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll n, m, a[N];
ll bexpo (ll x, ll n, ll m)
{
	ll r = 1;
	while (n > 0)
	{
		if (n % 2) r = (r * x) % m;
		x = (x * x) % m;
		n = n / 2;
	}
	return r;
}
ll ans[N];
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	cin >> n;
	for (ll i = 1; i <= n; i++)
	{
		ll d;
		cin >> d;
		a[d]++;
	}
	ll ok = 0;
	for (ll i = 2; i < N; i++)
	{
		ll temp = 0;
		for (ll j = i; j < N; j += i)
			temp += a[j];
		temp = (temp * bexpo (2, temp - 1, MOD)) % MOD;
		ans[i] = temp;
	}
	for (ll i = N - 1; i > 1; i--)
	{
		for (ll j = 2 * i; j < N; j += i)
		{
			ans[i] -= ans[j];
			ans[i] %= MOD;
			ans[i] += MOD;
			ans[i] %= MOD;
		}
		ok = (ok + (i * ans[i]) % MOD) % MOD;
	}
	cout << ok;
	return 0;
}


#include<bits/stdc++.h>

#define fin() freopen("input.txt","r",stdin)
#define fout() freopen("out.txt","w",stdout)
#define ss(dp,n) memset (dp,n, sizeof (dp))
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define MOD 1000000007
#define N 1000005
#define LN 20
#define inf 1e18+5
#define fast_io  ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll n, m, a[N];
ll bexpo (ll x, ll n, ll m)
{
	ll r = 1;
	while (n > 0)
	{
		if (n % 2) r = (r * x) % m;
		x = (x * x) % m;
		n = n / 2;
	}
	return r;
}
ll sum[N];
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	cin >> n;
	for (ll i = 2; i < N; i++)
	{
		for (ll j = 2 * i; j < N; j += i)
			sum[j] += i, sum[j] %= MOD;
	}
	for (ll i = 1; i <= n; i++)
	{
		ll d;
		cin >> d;
		a[d]++;
	}
	ll ans = 0;
	for (ll i = 2; i < 10; i++)
	{
		ll temp = 0;
		for (ll j = i; j < 10; j += i)
			temp += a[j];
		temp = (temp * bexpo (2, temp - 1, MOD)) % MOD;
		ll pro = (i - sum[i]) % MOD;
		pro = (pro + MOD) % MOD;
		temp = (temp * pro) % MOD;
		ans = (ans + temp) % MOD;
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>

const long long MOD = 1e9 + 7;
typedef long long ll;

int cnt[1000005];

ll fast(ll a, ll b){
	if(b==0) return 1;
	ll tmp=fast(a,b/2)%MOD;
	if(b%2==0) return (tmp*tmp)%MOD;
	return ((tmp*tmp)%MOD*a)%MOD;
}

int DP[1000005];
void dp(){
	for(int i=2; i<=1000000; i++){
		DP[i]+=i;
		for(int j=i*2; j<=1000000; j+=i){
			DP[j]-=DP[i];
		}
	}
}

int main(){
	int n,num;
	dp();
	scanf("%d",&n);
	for(int i=0; i<=1000000; i++) cnt[i]=0;
	for(int i=0; i<n; i++){
		scanf("%d",&num);
		int tmp=sqrt(num);
		for(int j=1; j<=tmp; j++){
			if(num%j==0){
				if(j*j!=num){
					cnt[j]++;
					cnt[num/j]++;
				}
				else cnt[j]++;
			}
		}
	}
	long long res=0;
	for(int i=2; i<=1000000; i++){
		if(cnt[i]>0){
			res+=(cnt[i]*(ll)DP[i])%MOD*fast(2,cnt[i]-1);
			res%=MOD;
//			printf("%lld\n",res);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include<bits/stdc++.h>

const long long MOD = 1e9 + 7;
typedef long long ll;

ll cnt[1000005];

ll fast(ll a, ll b){
	if(b==0) return 1;
	ll tmp=fast(a,b/2)%MOD;
	if(b%2==0) return (tmp*tmp)%MOD;
	return ((tmp*tmp)%MOD*a)%MOD;
}

ll DP[1000005];
void dp(){
	for(int i=2; i<=1000000; i++){
		DP[i]+=i;
		for(int j=i*2; j<=1000000; j+=i){
			DP[j]-=DP[i];
		}
	}
}

int main(){
	int n,num;
	dp();
	scanf("%d",&n);
	for(int i=0; i<=1000000; i++) cnt[i]=0;
	for(int i=0; i<n; i++){
		scanf("%d",&num);
		int tmp=sqrt(num);
		for(int j=1; j<=tmp; j++){
			if(num%j==0){
				if(j*j!=num){
					cnt[j]++;
					cnt[num/j]++;
				}
				else cnt[j]++;
			}
		}
	}
	long long res=0;
	for(int i=2; i<=1000000; i++){
		if(cnt[i]>0){
			res+=(cnt[i]*DP[i])%MOD*fast(2,cnt[i]-1);
			res%=MOD;
//			printf("%lld\n",res);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include<bits/stdc++.h>

const long long MOD = 1e9 + 7;
typedef long long ll;

ll gc[1000005];

ll fast(ll a, ll b){
	if(b==0) return 1;
	ll tmp=fast(a,b/2)%MOD;
	if(b%2==0) return (tmp*tmp)%MOD;
	return ((tmp*tmp)%MOD*a)%MOD;
}

ll DP[1000005];
void dp(){
	DP[2]=2;
	DP[3]=3;
	int tmp;
	for(int i=4; i<=1000000; i++){
		DP[i]=i;
		tmp = sqrt(i);
		for(int j=2; j<=tmp; j++) if(i%j==0){
			DP[i]-=DP[j];
			if(j*j!=i) DP[i]-=DP[i/j];
		}
	}
}

int main(){
	int n,num;
	dp();
//	printf("%d\n",DP[12]);
	scanf("%d",&n);
	for(int i=0; i<=1000000; i++) gc[i]=0;
	for(int i=0; i<n; i++){
		scanf("%d",&num);
		int tmp=sqrt(num);
		for(int j=1; j<=tmp; j++){
			if(num%j==0){
				if(j*j!=num){
					gc[j]++;
					gc[num/j]++;
				}
				else gc[j]++;
			}
		}
	}
	long long res=0;
	for(int i=2; i<=1000000; i++){
		if(gc[i]>0){
			res+=(gc[i]*DP[i])%MOD*fast(2,gc[i]-1);
			res%=MOD;
//			printf("%lld\n",res);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include<bits/stdc++.h>

const long long MOD = 1e9 + 7;
typedef long long ll;

ll cnt[1000005];

ll fast(ll a, ll b){
	if(b==0) return 1;
	ll tmp=fast(a,b/2)%MOD;
	if(b%2==0) return (tmp*tmp)%MOD;
	return ((tmp*tmp)%MOD*a)%MOD;
}

int DP[1000005];
void dp(){
	for(int i=2; i<=1000000; i++){
		DP[i]+=i;
		for(int j=i*2; j<=1000000; j+=i){
			DP[j]-=DP[i];
		}
	}
}

int main(){
	int n,num;
	dp();
	scanf("%d",&n);
	for(int i=0; i<=1000000; i++) cnt[i]=0;
	for(int i=0; i<n; i++){
		scanf("%d",&num);
		int tmp=sqrt(num);
		for(int j=1; j<=tmp; j++){
			if(num%j==0){
				if(j*j!=num){
					cnt[j]++;
					cnt[num/j]++;
				}
				else cnt[j]++;
			}
		}
	}
	long long res=0;
	for(int i=2; i<=1000000; i++){
		if(cnt[i]>0){
			res+=(cnt[i]*(ll)DP[i])%MOD*fast(2,cnt[i]-1);
			res%=MOD;
//			printf("%lld\n",res);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include<bits/stdc++.h>

const long long MOD = 1e9 + 7;
typedef long long ll;

int gc[1000005];

ll fast(ll a, ll b){
	if(b==0) return 1;
	ll tmp=fast(a,b/2)%MOD;
	if(b%2==0) return (tmp*tmp)%MOD;
	return ((tmp*tmp)%MOD*a)%MOD;
}

int DP[1000005];
void dp(){
	DP[2]=2;
	DP[3]=3;
	int tmp;
	for(int i=4; i<=1000000; i++){
		DP[i]=i;
		tmp = sqrt(i);
		for(int j=2; j<=tmp; j++) if(i%j==0){
			DP[i]-=DP[j];
			if(j*j!=i) DP[i]-=DP[i/j];
		}
	}
}

int main(){
	int n,num;
	dp();
//	printf("%d\n",DP[12]);
	scanf("%d",&n);
	memset(gc,0,sizeof(gc));
	for(int i=0; i<n; i++){
		scanf("%d",&num);
		int tmp=sqrt(num);
		for(int j=1; j<=tmp; j++){
			if(num%j==0){
				if(j*j!=num){
					gc[j]++;
					gc[num/j]++;
				}
				else gc[j]++;
			}
		}
	}
	long long res=0;
	for(int i=2; i<=1000000; i++){
		if(gc[i]>0){
			res+=(gc[i]*DP[i])%MOD*fast(2,gc[i]-1);
			res%=MOD;
//			printf("%lld\n",res);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include<bits/stdc++.h>

const long long MOD = 1e9 + 7;
typedef long long ll;

int gc[1000005];

ll fast(ll a, ll b){
	if(b==0) return 1;
	ll tmp=fast(a,b/2)%MOD;
	if(b%2==0) return (tmp*tmp)%MOD;
	return ((tmp*tmp)%MOD*a)%MOD;
}

int DP[1000005];
void dp(){
	DP[2]=2;
	DP[3]=3;
	int tmp;
	for(int i=4; i<=1000000; i++){
		DP[i]=i;
		tmp = sqrt(i);
		for(int j=2; j<=tmp; j++) if(i%j==0){
			DP[i]-=j;
			if(j*j!=i) DP[i]-=i/j;
		}
	}
}

int main(){
	int n,num;
	dp();
	scanf("%d",&n);
	memset(gc,0,sizeof(gc));
	for(int i=0; i<n; i++){
		scanf("%d",&num);
		int tmp=sqrt(num);
		for(int j=1; j<=tmp; j++){
			if(num%j==0){
				if(j*j!=num){
					gc[j]++;
					gc[num/j]++;
				}
				else gc[j]++;
			}
		}
	}
	long long res=0;
	for(int i=2; i<=1000000; i++){
		if(gc[i]>0){
			res+=(gc[i]*DP[i])%MOD*fast(2,gc[i]-1);
			res%=MOD;
//			printf("%lld\n",res);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include<iostream>

using namespace std;

typedef long long int ll;

const ll NMAX = 1e6;
const ll MOD = 1e9 + 7;

ll freq[1 + NMAX];
ll cnt[1 + NMAX];
ll dp[1 + NMAX];
ll t[1 + NMAX];
ll x, s;

int main()
{
  ll n, a;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    freq[a]++;
  }

  for(int i = 2; i <= NMAX; i++)
    for(int j = i; j <= NMAX; j += i)
      cnt[i] += freq[j];
  t[0] = 1;
  for(int i = 1; i <= NMAX; i++)
    t[i] = (2 * t[i - 1]) % MOD;
  for(int i = NMAX; i >= 2; i--) {
    dp[i] = (cnt[i] * t[cnt[i] - 1]) % MOD;
    x = 0;
    for(int j = 2 * i; j <= NMAX; j += i)
      x = (x + dp[j]) % MOD;
    dp[i] = (dp[i] - x + MOD) % MOD;
    s = (s + (i * dp[i]) % MOD) % MOD;}
  cout << s << '\n';
}


#include<iostream>

using namespace std;

typedef long long ll;

const int NMAX = 1e6;
const int MOD = 1e9 + 7;

ll freq[1 + NMAX];
ll cnt[1 + NMAX];
ll dp[1 + NMAX];
ll t[1 + NMAX];
ll x, s;

int main()
{
  long long n, a;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    freq[a]++;
  }

  for(int i = 2; i < NMAX; i++)
    for(int j = i; j < NMAX;j += i)
      cnt[i] += freq[j];

  t[0] = 1;
  for(int i = 1; i < NMAX; i++)
    t[i] = (2 * t[i - 1]) % MOD;
	for(int i = NMAX - 1; i >= 2; i--) {
      dp[i] = (cnt[i] * t[cnt[i] - 1]) % MOD;
      x = 0;
      for(int j = 2 * i; j < NMAX; j += i)
        x = (x + dp[j]) % MOD;
      dp[i] = (dp[i] - x + MOD) % MOD;
      s = (s + (i * dp[i]) % MOD) % MOD;}

  cout << s << '\n';
}


#include<iostream>

using namespace std;

typedef long long int ll;

const int NMAX = 1e6;
const int MOD = 1e9 + 7;

ll freq[1 + NMAX];
ll cnt[1 + NMAX];
ll dp[1 + NMAX];
ll t[1 + NMAX];
ll x, s;

int main()
{
  ll n, a;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    freq[a]++;
  }

  for(int i = 2; i < NMAX; i++)
    for(int j = i; j < NMAX;j += i)
      cnt[i] += freq[j];

  t[0] = 1;
  for(int i = 1; i < NMAX; i++)
    t[i] = (2 * t[i - 1]) % MOD;
	for(int i = NMAX - 1; i >= 2; i--) {
      dp[i] = (cnt[i] * t[cnt[i] - 1]) % MOD;
      x = 0;
      for(int j = 2 * i; j < NMAX; j += i)
        x = (x + dp[j]) % MOD;
      dp[i] = (dp[i] - x + MOD) % MOD;
      s = (s + (i * dp[i]) % MOD) % MOD;}

  cout << s << '\n';
}


#include<iostream>

using namespace std;

typedef long long int ll;

const ll NMAX = 1e6;
const ll MOD = 1e9 + 7;

ll freq[1 + NMAX];
ll cnt[1 + NMAX];
ll dp[1 + NMAX];
ll t[1 + NMAX];
ll x, s;

int main()
{
  ll n, a;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    freq[a]++;
  }

  for(int i = 2; i < NMAX; i++)
    for(int j = i; j < NMAX;j += i)
      cnt[i] += freq[j];

  t[0] = 1;
  for(int i = 1; i < NMAX; i++)
    t[i] = (2 * t[i - 1]) % MOD;
	for(int i = NMAX - 1; i >= 2; i--) {
      dp[i] = (cnt[i] * t[cnt[i] - 1]) % MOD;
      x = 0;
      for(int j = 2 * i; j < NMAX; j += i)
        x = (x + dp[j]) % MOD;
      dp[i] = (dp[i] - x + MOD) % MOD;
      s = (s + (i * dp[i]) % MOD) % MOD;}

  cout << s << '\n';
}


#include<iostream>

using namespace std;

typedef long long int ll;

const ll NMAX = 1e6;
const ll MOD = 1e9 + 7;

ll freq[1 + NMAX];
ll cnt[1 + NMAX];
ll dp[1 + NMAX];
ll t[1 + NMAX];
ll x, s;

int main()
{
  ll n, a;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a;
    freq[a]++;
  }

  for(int i = 2; i < NMAX; i++)
    for(int j = i; j < NMAX;j += i)
      cnt[i] += freq[j];

  t[0] = 1;
  for(int i = 1; i < NMAX; i++)
    t[i] = (2 * t[i - 1]) % MOD;
  for(int i = NMAX - 1; i >= 2; i--) {
    dp[i] = (cnt[i] * t[cnt[i] - 1]) % MOD;
    x = 0;
    for(int j = 2 * i; j < NMAX; j += i)
      x = (x + dp[j]) % MOD;
    dp[i] = (dp[i] - x + MOD) % MOD;
    s = (s + (i * dp[i]) % MOD) % MOD;}
  cout << s << '\n';
}


#include <iostream>
#include <vector>

#define M 1000001
#define P 78498
#define N 100001
#define Mod 1000000007
using namespace std;

int cnt[M]={0},ans[M]={0};
int two[200001];

int main() {

	int n,x,i,j;
	long long int over=0;

	two[0]=1;
	for (i=1;i<N;i++) {
		two[i]=2*two[i-1];
		two[i]%=Mod;
	}
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> x;
		cnt[x]++;
	}

	for (i=2;i<M;i++) {
		for (j=2*i;j<M;j+=i) {
			cnt[i]+=cnt[j];
		}
	}

	for (i=M-1;i>1;i--) {
		over=cnt[i];
		if (over==0) continue;
		over*=two[cnt[i]-1];
		over%=Mod;
		ans[i]=over;
		for (j=2*i;j<M;j+=i) {
			ans[i]-=ans[j];
			ans[i]%=Mod;
		}
	}
	long long int res=0;
	for (i=2;i<M;i++) {
		over=i;
		over*=ans[i];
		over%=Mod;
		res+=over;
		res%=Mod;
	}
	cout << res << '\n';

	return 0;
}