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: Time Limit Exceeded)

/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;
const int MAX = 1e6 + 100;
int n;
ll v[N];
map<int, int> mp[N];
map<int, int> gl;
int primes[MAX];
void sieve() {
    for(int i = 1; i < MAX; ++i) {
        primes[i] = i;
    }
    for(ll i = 2; i < MAX; ++i) {
        if(primes[i] == i) {
            for(ll k = i * i; k < MAX; k += i) {
                if(primes[k] == k) {
                    primes[k] = i;
                }
            }
        }
    }
}
void factor(ll d, int idx) {
    while(primes[d] != 1) {
        int p = primes[d];
        mp[idx][p]++;
        d /= primes[d];
    }
    for(auto i : mp[idx]) {
        gl[i.first] = max(gl[i.first], i.second);
    }
}
ll add(ll a, ll b) {
    return ( (a % MOD) + (b % MOD) ) % MOD;
}
ll mul(ll a, ll b) {
    return ( (a % MOD) * (b % MOD) ) % MOD;
}
ll bpow(ll a, ll b) {
    ll ret = 1;
    while(b) {
        if(b & 1) ret = mul(ret, a);
        a = mul(a, a);
        b >>= 1;
    }
    return ret;
}
int main() {
    sieve();
    cin >> n;
    forn(i, n) {
        cin>> v[i];
        factor(v[i], i);
    }
    ll ans = 0;
    forn(i, n) {
        ll cur = 1;
        for(auto k : gl) {
            if(mp[i].count(k.first)) {
                int diff = k.second - mp[i][k.first];
                ll pw = bpow(k.first, diff);
                cur = mul(cur, pw);
            } else {
                ll pw = bpow(k.first, k.second);
                cur = mul(cur, pw);
            }
        }
        ans = add(ans, cur);
    }
    cout<< ans << endl;
    return 0;
}