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: Wrong Answer)

#include"bits/stdc++.h"	// include
using namespace std;	// 名前空間
/* typedef */
typedef long long ll;	// long long
typedef long double ld;	// long double
typedef vector<int> vint; // intのvector
typedef vector<double> vdouble; // doubleのvector
typedef vector<ll> vll; // llのvector
typedef vector<ld> vld; // ldのvector
typedef vector<pair<ll, ll>> vl_l; // l_lのvector
typedef vector<pair<int, int>> vi_i; // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<string> vstring;	// stringのvector
typedef pair<ll, ll> l_l;	// ll同士のpair
typedef pair<int, int> i_i;	// int同士のpair
typedef pair<double, double> d_d;	// double同士のpair
/* define */
#define pb push_back	// push_back
#define all(v) v.begin(),v.end()	// コンテナ全体
#define PI (acos(-1))  // 円周率pi
#define rpt0(i, n) for(ll i = 0; i < (n); i++)  // リピート 0からn - 1まで
#define rpt1(i, n) for(ll i = 1; i <= (n); i++)  // リピート 1からnまで
#define rptb0(i ,n) for(ll i = (n) - 1; i >= 0; --i) // バックするリピート n - 1から0まで
#define rptb1(i ,n) for(ll i = (n); i >= 1; --i) // バックするリピート nから1まで
/* 入出力 read, write */
template <typename T>	// 1変数
void read(T& x) {
    cin >> x;
}
template <typename T, typename T0>	// 2変数
void read(T& x, T0& y) {
    cin >> x >> y;
}
template <typename T, typename T0, typename T1>	// 3変数
void read(T& x, T0& y, T1& z) {
    cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void read(T& x, T0& y, T1& z, T2& w) {
    cin >> x >> y >> z >> w;
}
template <typename T>	// vector
void read(vector< T >& oneD, int n) {
    ll n1 = (ll)n;
    rpt0(i, n1)
    {
        ll x;
        read(x);
        oneD.push_back(x);
    }
}
template <typename T>
void read(vector< T >& oneD, ll n) {
    rpt0(i, n)
    {
        ll x;
        read(x);
        oneD.push_back(x);
    }
}
template <typename T>	// 配列
void read(T oneD[], int n) {
    ll n1 = (ll)n;
    rpt0(i, n1) {
        read(oneD[i]);
    }
}
template <typename T>
void read(T oneD[], ll n) {
    rpt0(i, n) {
        read(oneD[i]);
    }
}
template <typename T, typename T0>	// pair
void read(pair< T, T0 >& p) {
    cin >> p.first >> p.second;
}
template <typename T>	// 1変数
void write(T& x) {
    cout << x << endl;
}
template <typename T, typename T0>	// 2変数
void write(T& x, T0& y) {
    cout << x << " " << y << endl;
}
template <typename T, typename T0, typename T1>	// 3変数
void write(T& x, T0& y, T1& z) {
    cout << x << " " << y << " " << z << endl;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void write(T& x, T0& y, T1& z, T2& w) {
    cout << x << " " << y << " " << z << " " << w << endl;
}
template <typename T>	// vector
void write(vector< T >& oneD, int n) {
    ll n1 = (ll)n;
    rpt0(i, n1) {
        cout << oneD[i] << " ";
    }
    cout << endl;
}
template <typename T>
void write(vector< T >& oneD, ll n) {
    rpt0(i, n) {
        cout << oneD[i] << " ";
    }
    cout << endl;
}
template <typename T>	// 配列
void write(T oneD[], int n) {
    ll n1 = (ll)n;
    rpt0(i, n1) {
        write(oneD[i]);
    }
    cout << endl;
}
template <typename T>
void write(T oneD[], ll n) {
    rpt0(i, n) {
        write(oneD[i]);
    }
    cout << endl;
}
template <typename T, typename T0>	// pair
void write(pair< T, T0 >& p) {
    cout << p.first << " " << p.second << " ";
    cout << endl;
}


const ll MAX = 1000000007;

// 最大公約数
ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		gcd(b, a % b);
	}
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(int argc, char const *argv[])
{
    ll n; read(n);
    vll a;
    a.resize(n);
    for (ll rv = 0; rv < n; rv++) {
        cin >> a[rv];
    }
    vll c(a);
    sort(all(a));
    for (ll i = 0; i < n - 1; i++) {
        c[i + 1] = lcm(c[i + 1], c[i]);
    }
    vll b;
    b.resize(n);
    for (ll rv = 0; rv < n; rv++) {
        // a を 10000000007 で割ってから b の逆元をかけて計算
        c[n - 1] %= MAX;
        b[rv] = c[n - 1] * modinv(a[rv], MAX) % MAX;
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans += b[i];
        ans = ans % MAX;
    }
    write(ans);

   return 0;
}