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).



Sample input:
3
2 3 4


Sample output:
13

Submission status: Runtime Error

Solution code:
import fractions

from numba import njit
import numpy as np
from sys import stdin


@njit
def calc_ans(a, lcm):
    ans = 0

    for ai in a:
        ans += lcm // ai

    ans %= 10 ** 9 + 7

    return ans


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))
    sa = set(a)
    a = np.array(a)

    lcm = 1

    for ai in sa:
        lcm = (ai * lcm) // fractions.gcd(ai, lcm)

    print(calc_ans(a, lcm))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions

from numba import njit
import numpy as np
from sys import stdin


@njit(cache=True)
def calc_ans(a, lcm):
    ans = 0

    for ai in a:
        ans += lcm // ai

    ans %= 10 ** 9 + 7

    return ans


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))
    sa = set(a)
    a = np.array(a)

    lcm = 1

    for ai in sa:
        lcm = (ai * lcm) // fractions.gcd(ai, lcm)

    print(calc_ans(a, lcm))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions

from numba import njit, prange
import numpy as np
from sys import stdin


@njit(cache=True)
def calc_ans(n, a, lcm):
    ans = 0

    for i in prange(n):
        ans += lcm // a[i]

    ans %= 10 ** 9 + 7

    return ans


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))
    sa = set(a)
    a = np.array(a)

    lcm = 1

    for ai in sa:
        lcm = (ai * lcm) // fractions.gcd(ai, lcm)

    ans = 0

    for i in prange(n):
        ans += lcm // a[i]

    ans %= 10 ** 9 + 7

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions

from numba import njit
from sys import stdin


@njit
def calc_ans(a, lcm):
    ans = 0

    for ai in a:
        ans += lcm // ai

    ans %= 10 ** 9 + 7

    return ans


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))
    sa = set(a)

    lcm = 1

    for ai in sa:
        lcm = (ai * lcm) // fractions.gcd(ai, lcm)

    print(calc_ans(a, lcm))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

from sys import stdin
from numba import njit


@njit
def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))
    sa = set(a)

    lcm = 1

    for ai in sa:
        lcm = (ai * lcm) // fractions.gcd(ai, lcm)

    ans = 0

    ans = np.sum([lcm // ai for ai in a])

    ans %= 10 ** 9 + 7

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    lcm = a[0]

    for i in range(1, n):
        lcm = (a[i] * lcm) // fractions.gcd(a[i], lcm)

    ans = 0

    for ai in a:
        ans += lcm // ai
        ans %= 10 ** 9 + 7

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
// #include <bits/stdc++.h>
#include <iostream>  // cin, cout, string
#include <algorithm> // sort, min/max, upper/lower_bound, transform, count/copy_if
#include <vector>
#include <utility> // pair, swap
#include <functional>
#include <iomanip> // setprecision
#include <map>
#include <set> // multiset
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <stack>
#include <queue> // priority_queue
#include <deque>
#include <bitset>
#include <array>
#include <list>
#include <forward_list>
#include <complex>
#include <ratio>
#include <cassert>
#include <numeric> // accumulate, itoa
#include <random>  // mt19937
#include <iterator>
#include <chrono>
#include <cstring>

using namespace std;

// #define int long long

using i64 = int64_t;
using ll = long long;
using ld = long double;

template <typename T>
using vec = vector<T>;
template <typename T>
using mat = vec<vec<T>>;
template <typename T>
using dic = unordered_map<string, T>;
template <typename T>
using pqg = priority_queue<T, vector<T>, greater<T>>; // dijkstra
// template<typename T, typename U> using P = pair<T, U>;
// template<typename... Args> using func = function<Args...>;
// template<typename T> using pq = priority_queue<T>;

using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pip = pair<int, pii>;
using ppp = pair<pii, pii>;

using vi = vec<int>;
using mi = mat<int>; // Graph
using vp = vec<pii>;

constexpr int IINF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
// constexpr int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
constexpr long long MOD = 1e9 + 7;

#define _overload(_1, _2, _3, name, ...) name
#define _rep1(i, a, b) for (int i = (a), _##i = (b); i < _##i; ++i)
#define _rep2(i, n) _rep1(i, 0, n)
#define _rep3(n) _rep2(i, n)
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2, _rep3)(__VA_ARGS__)
#define _rrep1(i, a, b) for (int i = (b)-1, _##i = (a); i >= _##i; --i)
#define _rrep2(i, n) _rrep1(i, 0, n)
#define _rrep3(n) _rrep2(i, n)
#define rrep(...) _overload(__VA_ARGS__, _rrep1, _rrep2, _rrep3)(__VA_ARGS__)

#define each(i, a) for (auto &&i : a)
#define each2(i, a) for (const auto &i : a)

#define pb push_back
// emplace_back(*) == push_back(constructor(*))
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front

#define np next_permutation
#define pp prev_permutation

// make_pair(A, B) == pair<T, U>(A, B)
#define mp make_pair
// mt(...) == tie(...)
#define mt make_tuple

#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))
#define rs(a, l) (a).resize(l)

#define upper(s) transform(all(s), (s).begin(), topper)
#define lower(s) transform(all(s), (s).begin(), tolower)

#define sum(a) accumulate(all(a), 0)
#define elif else if
#define unless(a) if (!(a))
#define qt(a) #a

#define endl '\n'
#define dec(n) fixed << setprecision(n)
#define zfl(n) setfill(‘0’) << setw(n)

template <typename T = int, T l = 0, T r = (T)MOD>
auto rnd = bind(uniform_int_distribution<T>(l, r), mt19937(chrono::steady_clock::now().time_since_epoch().count()));

template <typename T>
inline constexpr T gcd(T a, T b)
{
    if (a == 0 || b == 0)
        return 0;
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <typename T>
inline constexpr T extgcd2(T a, T b, T &x, T &y)
{
    x = 1;
    y = 0;
    while (b)
    {
        T t = a / b;
        a -= t * b;
        swap(a, b);
        x -= t * y;
        swap(x, y);
    }
    return a;
}
template <typename T>
inline constexpr T lcm(T a, T b) { return a / gcd(a, b) * b; }

template <typename T>
inline constexpr bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline constexpr bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename B>
istream &operator>>(istream &is, pair<A, B> &p)
{
    is >> p.first;
    is >> p.second;
    return is;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << p.first << " " << p.second;
    return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &&x : v)
        is >> x;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < (int)v.size(); ++i)
        cout << v[i] << (i + 1 != (int)v.size() ? " " : "");
    return os;
}

#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg>
void __f(const char *name, const Arg &arg)
{
    cerr << name << " : " << arg << endl;
}
template <typename Arg, typename... Args>
void __f(const char *names, const Arg &arg, const Args &... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg << " | ";
    __f(comma + 1, args...);
}

inline auto yes(const bool &c) { return c ? "yes" : "no"; }
inline auto Yes(const bool &c) { return c ? "Yes" : "No"; }
inline auto YES(const bool &c) { return c ? "YES" : "NO"; }
inline auto Possible(const bool &c) { return c ? "Possible" : "Impossible"; }
inline auto POSSIBLE(const bool &c) { return c ? "POSSIBLE" : "IMPOSSIBLE"; }

constexpr int lim = 100007; // 10^5+7

int n;

map<ll, ll> L;
vec<ll> p;
ll a_max = 1000000;

void setPrime()
{
    bool f;
    rep(i, 2, a_max)
    {
        f = true;
        for (int j = 0; j < p.size(); j++)
        {
            ll pr = p.at(j);
            if (i % pr == 0)
            {
                f = false;
                break;
            }
            if (pr * pr > i)
            {
                break;
            }
        }

        if (f)
        {
            p.emplace_back(i);
            L.insert({i, 0});
        }
    }
}

ll mod_inv(ll a)
{
    ll b = MOD, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}

ll mod_pow(ll a, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    setPrime();
    // rep(p.size()) cout << p.at(i) << " ";
    cin >> n;
    ll ans = 0;
    rep(n)
    {
        ll a;
        cin >> a;
        ans = (ans + mod_inv(a)) % MOD;
        // cout << mod_inv(a) << endl;
        rep(p.size())
        {
            ll e = 0;
            while (a % p.at(i) == 0)
            {
                e++;
                a /= p.at(i);
            }
            L.at(p.at(i)) = max(L.at(p.at(i)), e);
        }
    }

    rep(p.size())
    {
        ans *= mod_pow(p.at(i), L.at(p.at(i)));
        // if (mod_pow(p.at(i), L.at(p.at(i))) > 1)
        //     cout << p.at(i) << " " << mod_pow(p.at(i), L.at(p.at(i))) << endl;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def ti(): return tuple(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

from functools import reduce

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    return gcd(b, r)

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def table(n:int, p=10**9+7):
    global fact, factinv, inv
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

def main():
    N = ii()
    A = ti()
    P = 10**9 + 7
    lcm_a = lcm(A) % P

    #逆元テーブルの作成
    N = 10**6+1
    inv_t = [0]+[1]
    for i in range(2,N):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

    ans = 0
    for num in A:
        ans = (ans + inv_t[num] * lcm_a) % P
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int, input().split()))

mod = 1000000007

l = 1

def lcm(a, b):
    return a * b // math.gcd(a, b)

for i in range(n):
    l = lcm(l, a[i])

ans = 0
for i in range(n):
    ans += l // a[i]
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce, lru_cache

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

@lru_cache
def lcm(x, y):
    return int(x*y)//int(gcd(x, y))

B = [1 for i in range(N)]
global_lcm = reduce(lcm, A)
ans = 0
for i in range(N):
    B[i] = int(global_lcm//A[i])
    ans += B[i] % MOD
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
import numpy as np

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
np_A = np.array(A)

B = [1 for i in range(N)]
global_lcm = np.lcm.reduce(np_A)
ans = 0
for i in range(N):
    B[i] = int(global_lcm//A[i])
    ans += B[i] % MOD
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

def lcm(x, y):
    return int(x*y/gcd(x, y))

B = [1 for i in range(N)]
global_lcm = reduce(lambda a, b : lcm(a, b), A)
for i in range(N):
    B[i] = int(global_lcm/A[i])
ans = 0
for i, b in enumerate(B):
    ans += b % MOD
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

def lcm(x, y):
    return int(x*y/gcd(x, y))

B = [1 for i in range(N)]
global_lcm = reduce(lambda a, b : lcm(a, b), A)
for i in range(N):
    B[i] = int(global_lcm/A[i])
ans = 0
for i, b in enumerate(B):
    ans += b
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

def lcm(x, y):
    return int(x*y/gcd(x, y))

B = [1 for i in range(N)]

for i in range(N):
    for j in range(i+1, N):

        pair_lcm = lcm(A[i], A[j])

        i_element = int(pair_lcm / A[i])
        B[i] *= int(lcm(B[i], i_element)/B[i])

        j_element = int(pair_lcm / A[j])
        B[j] *= int(lcm(j_element, B[j]) / B[j])

ans = 0
for i, b in enumerate(B):
    ans += b
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7

    # 素因数分解
    def prime_decomp(n):
        i = 2
        res = []
        while i ** 2 <= n:
            while n % i==0:
                n //= i
                res.append(i)
            i += 1
        if n > 1:
            res.append(n)
        return res
        # 素因数のリストを返す(0, 1は空)

    # aの逆元を求める
    def inv(a, mod=mod):
        return pow(a, mod-2, mod)

    n = int(input())
    a = list(map(int, input().split()))


    lcm = [0]*(max(a)+1)
    for i in a:
        l = prime_decomp(i)
        c = Counter(l)
        for k, v in c.items():
            if lcm[k] < v:
                lcm[k] = v
    
    b = 1
    for i in range(1000):
        if lcm[i] != 0:
            b *= pow(i, lcm[i], mod)
    
    if n == 1:
        print(1)
    else:
        res = 0
        for i in a:
            res += inv(i)
        print(res*b%mod)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7

    # 素因数分解
    def prime_decomp(n):
        i = 2
        res = []
        while i ** 2 <= n:
            while n % i==0:
                n //= i
                res.append(i)
            i += 1
        if n > 1:
            res.append(n)
        return res
        # 素因数のリストを返す(0, 1は空)

    # aの逆元を求める
    def inv(a, mod=mod):
        return pow(a, mod-2, mod)

    n = int(input())
    a = list(map(int, input().split()))


    lcm = [0]*1000
    for i in a:
        l = prime_decomp(i)
        c = Counter(l)
        for k, v in c.items():
            if lcm[k] < v:
                lcm[k] = v
    
    b = 1
    for i in range(1000):
        if lcm[i] != 0:
            b *= pow(i, lcm[i], mod)
    
    if n == 1:
        print(1)
    else:
        res = 0
        for i in a:
            res += inv(i)
        print(res*b%mod)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
from fractions import gcd

N=int(input())
A=list(map(int, input().split()))

p=10**9+7
n = 10 ** 4  # N は必要分だけ用意する
#fact = [1, 1]  # fact[n] = (n! mod p)
#factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用 逆元

for i in range(2, n + 1):
    #fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    #factinv.append((factinv[-1] * inv[-1]) % p)
#a//gcd(a,b)*b

def lcm(a,b):
    g=gcd(a,b)
    #return ((a*b)*pow(g,p-2,p))%p
    return a//gcd(a,b)*b

LCM=1
for x in A:
    LCM=lcm(LCM,x)



#print(LCM)
ans=0
LCM%=p
for i in range(N):
    ans+=(LCM*inv[A[i]])%p
    #ans+=(LCM*pow(A[i],p-2,p))%p
    ans%=p
print(ans)

Submission status: Runtime Error

Solution code:
class Sieve:
    """区間[2,n]の値を素因数分解する"""

    def __init__(self, n=1):
        primes = []
        f = [0] * (n + 1)
        f[0] = f[1] = -1
        for i in range(2, n + 1):  # 素数を探す
            if f[i]: continue
            primes.append(i)
            f[i] = i  # 素数には自身を代入
            for j in range(i * i, n + 1, i):  # 合成数に素因数を書き込む
                if not f[j]:
                    f[j] = i  # 最小の素因数を代入
        self.primes = primes
        self.f = f

    def is_prime(self, x) -> bool:  # 素数判定
        return self.f[x] == x

    def factor_list(self, x) -> list:  # 素因数分解の昇順リスト, [2,2,3,5,...]
        res = []
        while x != 1:
            res.append(self.f[x])
            x //= self.f[x]
        return res

    def factor(self, x) -> list:  # 素因数分解の頻度リスト, [[2,x],[3,y],[5,z],...]
        fl = self.factor_list(x)
        if not fl: return []
        res = [[fl[0], 0]]
        for p in fl:
            if res[-1][0] == p:
                res[-1][1] += 1
            else:
                res.append([p, 1])
        return res


def main():
    from collections import defaultdict

    MOD = 10 ** 9 + 7
    A_MX = 10 ** 6

    N = int(input())
    *a, = map(int, input().split())

    s = Sieve(n=A_MX)

    lcm = defaultdict(int)

    factors = []
    for x in a:
        f = [0] * (A_MX + 1)
        for prime, cnt in s.factor(x):
            lcm[prime] = max(lcm[prime], cnt)
            f[prime] = cnt
        factors.append(f)

    ans = 0
    for f in factors:
        t = 1
        for prime, cnt in lcm.items():
            power = max(0, cnt - f[prime])
            t *= pow(prime, power, MOD)
            t %= MOD
        ans += t
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd

N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
mod=10**9+7
def lcm(a,b):
    return a//gcd(a,b)*b

LCM=1
for x in A:
    LCM=lcm(LCM,x)



#print(LCM)
print(int((LCM//A).sum()%mod))

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
mod=10**9+7
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

def lcm_core(a,b):
    g = gcd_core(a,b)
    return ((a*b)//g)

def lcm(arr):
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
    return l

LCM=lcm(A)
#print(LCM)
print((LCM//A).sum()%mod)

Submission status: Runtime Error

Solution code:
import math
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

kbs = A[0]
for i in range(1,N):
  kbs = kbs*A[i]*pow(math.gcd(kbs,A[i]),mod-2,mod)
  kbs %= mod
  
ans = 0
for i in range(N):
  ans += kbs*pow(A[i],mod-2,mod)
  ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    from fractions import gcd
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    lsd = a[0]
    for i in range(1, n):
        lsd = int((lsd * a[i]) / (gcd(lsd, a[i])))
 
    ans = 0
    for i in range(n):
        ans += int(lsd/a[i]) % mod
 
    print(int(ans % mod))
resolve()

Submission status: Runtime Error

Solution code:
def resolve():
    from fractions import gcd
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    lsd = a[0]
    for i in range(1, n):
        lsd = int((lsd * a[i]) / (gcd(lsd, a[i])))

    ans = 0
    for i in range(n):
        ans += (lsd/a[i]) % mod

    print(int(ans % mod))

resolve()

Submission status: Runtime Error

Solution code:
from fractions import gcd

MOD = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))

tmp = 1
for a in A:
    tmo *= a // gcd(tmp, a)

ans = 0
for a in A:
    ans += (tmp // a) % MOD
    ans %= MOD

print (ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

MOD = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))

tmp = 1
for a in A:
    tmo *= a // gcd(tmp, a)

ans = 0
for a in A:
    ans += (tmp // a) MOD
    ans %= MOD

print (ans)

Submission status: Runtime Error

Solution code:
def resolve():
    from fractions import gcd
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9 + 7
    lsd = a[0]
    for i in range(1, n):
        lsd = (lsd * a[i]) // gcd(lsd, a[i])

    ans = 0
    for i in range(n):
        ans += (lsd/a[i]) % mod

    print(int(ans % mod))

resolve()

Submission status: Runtime Error

Solution code:
from collections import gcd

MOD = 10 ** 9 + 7

N = int(input())

A = list(map(int, input().split()))

B = [1] * (N + 1)

for index, a in enumerate(A):
    tmp = gcd(B[index], a)
    B[index + 1] = B[index] * a // tmp

C = [1] * (N + 1)
for i in range(N - 1, -1, -1):
    tmp =gcd(C[i + 1], A[i])
    C[i] = C[i + 1] * A[i] // tmp

# print (B)
# print (C)

ans = 0
for i in range(N):
    tmp1 = gcd(B[i], C[i + 1])
    tmp2 = B[i] * C[i + 1] // tmp1

    tmp3 = gcd(tmp2, A[i])
    tmp4 = tmp2 * A[i] // tmp3

    ans += (tmp4 // A[i] % MOD)
    ans %= MOD

    # print (ans)

print (ans)

Submission status: Runtime Error

Solution code:
from math import gcd

MOD = 10 ** 9 + 7

N = int(input())

A = list(map(int, input().split()))

B = [1] * (N + 1)

for index, a in enumerate(A):
    tmp = gcd(B[index], a)
    B[index + 1] = B[index] * a // tmp

C = [1] * (N + 1)
for i in range(N - 1, -1, -1):
    tmp =gcd(C[i + 1], A[i])
    C[i] = C[i + 1] * A[i] // tmp

# print (B)
# print (C)

ans = 0
for i in range(N):
    tmp1 = gcd(B[i], C[i + 1])
    tmp2 = B[i] * C[i + 1] // tmp1

    tmp3 = gcd(tmp2, A[i])
    tmp4 = tmp2 * A[i] // tmp3

    ans += (tmp4 // A[i] % MOD)
    ans %= MOD

    # print (ans)

print (ans)

Submission status: Runtime Error

Solution code:
def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
l = 1
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    if y > x: x,y = y,x
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(x, y):
    return int((x*y) /gcd(x,y))

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
l = 1
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    if y > x: x,y = y,x
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(x, y):
    return int((x*y) /gcd(x,y))

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(x, y):
    return int((x*y) /gcd(x,y))

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
from fractions import math
def lcm(x, y):
    return int((x*y) /gcd(x,y))

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
import math
def lcm(x, y):
    return int((x*y) /math.gcd(x,y))

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(n):
    l = lcm(l, a[i])
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
import math
def lcm(x, y):
    return int((x*y) /math.gcd(x,y))

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
before = a[0]
l = 0
for i in range(1,n):
    l = lcm(before, a[i])
    before = l
for i in range(n):
    ans += l / a[i]
print(int(ans%MOD))

Submission status: Runtime Error

Solution code:
import math
def lcm(x, y):
    return (x*y) /math.gcd(x,y)

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
before = a[0]
l = 0
for i in range(1,n):
    l = lcm(before, a[i])
    before = l
for i in range(n):
    ans += l / a[i]
print(ans%MOD)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
f=l[0]
from fractioins import gcd
#from math import gcd

for i in l:
    f=f*i//gcd(f,i)
mod=10**9+7
print(sum((f//a)%mod for a in l )%mod)

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

from fractions import Fraction

mod = 10**9+7

n = ni()
a = na()
b,c = 1,0

def lcm(m,n):
    return (m*n)//Fraction.gcd(m,n)

for i in a:
    b=lcm(b,i)

for i in a:
    c+=b//i

print(c%mod)

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

import math

mod = 10**9+7

n = ni()
a = na()
b,c = 1,0

def lcm(m,n):
    return (m*n)//math.gcd(m,n)

for i in a:
    b=lcm(b,i)

for i in a:
    c+=b//i

print(c%mod)

Submission status: Runtime Error

Solution code:
import math
def lcm(x, y):
    return (x*y) //math.gcd(x,y)

MOD = 10**9 + 7
ans = 0
n = int(input())
a = list(map(int, input().split()))
before = a[0]
l = 0
for i in range(1,n):
    l = lcm(before, a[i])
    before = l
for i in range(n):
    ans += l // a[i]
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
MOD = 10**9 + 7

N = int(input())
A = [int(i) for i in input().split()]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

LCM = lcm(*A)
ans = 0
for a in A:
    ans += LCM/a
    ans %= MOD

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
MOD = 10**9 + 7

N = int(input())
A = [int(i) for i in input().split()]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

LCM = lcm(*A)
ans = 0
for a in A:
    ans += LCM/a
    ans %= MOD

print(int(ans))

Submission status: Runtime Error

Solution code:
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b) 

n = int(input())
vet = input().split(' ');

mmc = int(1)
for i in vet:
    mmc = (int(mmc)*int(i))/gcd(int(mmc), int(i))
    
ans = int(0)
for i in vet:
    ans += int((int(mmc)/int(i))%1000000007);


print(int(ans)%1000000007)

Submission status: Runtime Error

Solution code:
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b) 

n = int(input())
vet = input().split(' ');

mmc = int(1)
for i in vet:
    mmc = (int(mmc)*int(i))/gcd(int(mmc), int(i))
    
ans = int(0)
for i in vet:
    ans += int(int(mmc)/int(i));


print(int(ans)%1000000007)

Submission status: Runtime Error

Solution code:
MOD=10**9+7
def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        if(tmp%i==0):
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if(not arr):
        arr.append([1,1])
    if(tmp!=1):
        arr.append([tmp,1])
    return arr
def moddiv(a,m):
    return pow(a,m-2,m)
N=int(input())
A=list(map(int,input().split()))
cnt=[0]*1001
for i in range(N):
    arr=factorization(A[i])
    for a,b in arr:
        cnt[a]=max(cnt[a],b)
g=1;res=0
for i in range(1001):
    g=g*(pow(i,cnt[i],MOD))%MOD
for i in range(N):
    res=(res+(g*moddiv(A[i],MOD))%MOD)%MOD
print(res)

Submission status: Runtime Error

Solution code:
MOD=10**9+7
def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        if(tmp%i==0):
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if(not arr):
        arr.append([1,1])
    if(tmp!=1):
        arr.append([tmp,1])
    return arr
def moddiv(a,m):
    return pow(a,m-2,m)
N=int(input())
A=list(map(int,input().split()))
cnt=[0]*1001
for i in range(N):
    arr=factorization(A[i])
    for a,b in arr:
        cnt[a]=max(cnt[a],b)
g=1;res=0
for i in range(1001):
    g=g*(i**cnt[i])%MOD
for i in range(N):
    res=(res+g*moddiv(A[i],MOD))%MOD
print(res)