Problem:
Score : 500 points

Problem Statement

Given are N positive integers A_1,...,A_N.

Consider positive integers B_1, ..., B_N that satisfy the following condition.

Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds.

Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.

Since the answer can be enormous, print the sum modulo (10^9 +7).

Constraints

1 \leq N \leq 10^4

1 \leq A_i \leq 10^6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the minimum possible value of B_1 + ... + B_N for B_1,...,B_N that satisfy the condition, modulo (10^9 +7).

Sample Input 1

3
2 3 4

Sample Output 1

13

Let B_1=6, B_2=4, and B_3=3, and the condition will be satisfied.

Sample Input 2

5
12 12 12 12 12

Sample Output 2

5

We can let all B_i be 1.

Sample Input 3

3
1000000 999999 999998

Sample Output 3

996989508

Print the sum modulo (10^9+7).

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
	ll n,a[1010];
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll b[1010][79000];	
	for(ll i=0;i<1010;i++){
		for(ll j=0;j<79000;j++){
			b[i][j]=0;
		}
	}
	vector<ll>so;
	for(ll i=2;i<=1000000;i++){
		if(IsPrime(i)){
			so.push_back(i);
		}
	}
//	cout << so[1]<<endl;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		ll j=0;
		while(now!=1){
			ll cnt=0;
			while(now%so[j]==0){
				now/=so[j];
				cnt++;
			}
			b[i][j]=cnt;
		//	cout <<cnt<<endl;
			b[n][j]=max(b[i][j],b[n][j]);
			j++;
		}
	}
//	cout << 0<<endl;
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll cnt=1;
		for(ll j=0;j<so.size();j++){
			ll sa=b[n][j]-b[i][j];
		//	cout << sa<<endl;
			if(sa>0){
				ll k=modpow(so[j], sa, 1000000007);
		//		cnt*=k;
				cnt%=inf;
			}
		}
		ans+=cnt;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}