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:
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        return modint(pow(self.value, MOD - 2, MOD))


def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x


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


def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    k = A[0]
    for a in A[1:]:
        k *= a//gcd(k, a)
    k = modint(k)
    ans = modint(0)
    for a in A:
        ans += k//a
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    import fractions
    import sys
    input = sys.stdin.readline
    n=int(input())
    a = tuple(map(int, input().split()))
    ans = a[0]

    mmm=10**9+7
    for i in a[1:]:
        ans = 8ans *i )// fractions.gcd(ans, i)

    result=0
    for item in a:
      result+=ans//item

    print(result%mmm)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
an = list(map(int, input().split()))


from fractions import gcd
from functools import reduce

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

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

lcma = lcm_list(an)
bn = []
for a in an:
    bn.append(lcma / a)

sumbn = sum(bn) % 1000000007

print(sumbn)

Submission status: Runtime Error

Solution code:
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

L = lcm(lst)
answer = int(sum(map(lambda x: L/x % const, lst)) % const)

print(answer)

Submission status: Runtime Error

Solution code:
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

L = lcm(lst)
answer = sum(map(lambda x: L/x % const, lst)) % const

print(answer)

Submission status: Runtime Error

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

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l/e
    mod = int(1000000007)
    print(int(s % mod))

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
lcm = 1
for v in a:
	lcm *= v//math.gcd(v,lcm)
ans = 0
for v in a:
	ans += lcm // v
print(ans%1000000007)

Submission status: Runtime Error

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

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

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split()))
    l = 1
    for e in a:
        l = lcm(l,e)
    s = 0
    for e in a:
        s += l/e
    mod = 1000000007
    print(int(s % mod))

Submission status: Runtime Error

Solution code:
from fractions import*
l=lambda x,y=x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
s=1
for i in a:s=l(s,i)
print(sum(s//i for i in a)%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
def LCM(a, b):
    return(a // math.gcd(a, b) * b)

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

for i in range(n):
    lc = LCM(lc, a[i])

res = 0;
for i in range(n):
    res = res + (lc // a[i])

print(res % 1000000007)

Submission status: Runtime Error

Solution code:
from functools import reduce
import math

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

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

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

N = int(input().rstrip())
As = input().rstrip().split(" ")
As = [int(p) for p in As]

cand = lcm_list(As)

sum = 0

for num in As:
    sum = sum + cand / num

print(int(sum % (10**9 + 7)))

Submission status: Runtime Error

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7


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

cnt=0
b=[ans//a[i] for i in range(n)]
print(sum(b)%mod)

Submission status: Runtime Error

Solution code:
import math
gcd = math.gcd
# from fractions import gcd


MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
#%%
def modinv(x,mod):
    return pow(x,mod-2,mod)

B = []
for a in A:
    b = modinv(a,MOD)
    B.append(b)

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

ans = 0

cur = 1
for a in A:
    cur =  lcm(cur,a)
for b in B:
    ans += cur*b
ans %= MOD
print(ans)

Submission status: Runtime Error

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


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


mod = 10**9+7
lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(ans % mod)

Submission status: Runtime Error

Solution code:
# 最小公倍数
from fractions import gcd
def lcm (x, y):
    return (x * y) // gcd(x, y)

# 最小公倍数(リスト)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm_A = lcm_list(A)

ans = 0
for i in range(N):
    ans += lcm_A // A[i]

print(ans % mod)

Submission status: Runtime Error

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

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

mod = 10 ** 9 + 7
N = n + 2

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

base = a[0]
for ai in a:
    base = lcm(base, ai)
ans = 0
for ai in a:
    ans = (ans + base * inv_t[ai]) % mod
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import math
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0

lcm = a[0]
for i in range(1, n):
    #lcm = lcm * a[i] // fractions.gcd(lcm, a[i])
    lcm = lcm * a[i] // math.gcd(lcm, a[i])
lcm %= MOD
for i in range(n):
    ans += lcm * pow(a[i] , MOD-2, MOD)
    ans %= MOD
print(ans)

Submission status: Runtime Error

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


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


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(int(ans % int(1e9+7)))

Submission status: Runtime Error

Solution code:
def main():
    from fractions import gcd
    import sys
    n=int(input())
    a = tuple(map(int, input().split()))
    ans = a[0]

    #mmm=10**9+7
    for i in a[1:]:
        ans = ans *i // gcd(ans, i)

    result=0
    for item in a:
      resul+=ans//item

    print(result%(10**9+7))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


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


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(int(ans % (1e9+7)))

Submission status: Runtime Error

Solution code:
import fractions

mod = 1e9 + 7;

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

l = A[0]
for i in range(1, N):
  l = l * A[i] // fractions.gcd(l, A[i])

sum = 0
for i in A:
  sum += l / i

print(int(sum % mod))

Submission status: Runtime Error

Solution code:
from fractions import gcd
n = int(input())
a = [int(x) for x in input().split()]
g = a[0]
if n>1:
    for idx in range(1,len(a)):
        g = a[idx]*g//gcd(a[idx],g)
ans = []
for i in range(n):
    ans.append(int(g/a[i]))
print(sum(ans)%(10**9+7))

Submission status: Runtime Error

Solution code:
import numpy as np
 
def gcd(a,b):
    if(b==0):
        return a
    return gcd(b,a%b)
 
def lcm(a,b):
    return a*b/gcd(a,b)
 
def main():
    n=int(input())
    a=inputList()
    
    lcm_all=a[0]
    for i in range(n):
        lcm_all=lcm(lcm_all,a[i])
 
 
    b=[lcm_all/a[i] for i in range(n)]
 
    sum_all=0
    for i in range(n):
        sum_all=sum_all+b[i]
 
    ans=sum_all%(10**9+7)
 
    print(int(ans))
 
def inputList():
    a=list(map(int,input().split()))
    return a
 
def multisort(li,index):
    return sorted(li,key=lambda x: x[index])
 
if(__name__=='__main__'):
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


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


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc / a[i])
print(int(ans % (1e9+7)))

Submission status: Runtime Error

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

a0 = min(a)
b0 = a0

if(n==1):
    print(1)
    exit()

for i in a:
    b0 = (b0 * i) // fractions.gcd(b0,i)
b0 = b0 / a0
count = 0
for i in a:
    count += a0*b0 // i
    count = count % (10**9 + 7)

print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


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


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
lc %= int(1e9+7)
for i in range(N):
    ans += (lc / a[i])
print(int(ans % (1e9+7)))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

n = int(input())
aa = list(map(int,input().split()))
           
l = lcm(*aa)        
ans = 0
for ai in aa:
  ans += l//ai

print(ans % MOD)

Submission status: Runtime Error

Solution code:
from fractions import gcd
n = int(input())
a = [int(x) for x in input().split()]
g = a[0]
if n>1:
    for idx in range(1,len(a)):
        g = a[idx]*g//math.gcd(a[idx],g)
ans = []
for i in range(n):
    ans.append(int(g/a[i]))
print(sum(ans)%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
import fractions
n = int(input())


l = list(int() ,input().split())

lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]
    ans%=1000000007
print(ans)

Submission status: Runtime Error

Solution code:
import fractions

mod = 1e9 + 7;

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

l = A[0]
for i in range(1, N):
  l = l * A[i] // fractions.gcd(l, A[i])

sum = 0
for i in A:
  sum += l / i
  sum %= mod

print(int(sum))

Submission status: Runtime Error

Solution code:

global MOD = 1000000007

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

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

def main():
    n = int(input())
    a = list(map(int,input().split()))
    all_lcm = a[0]
    for i in range(n):
        all_lcm = lcm(all_lcm, a[i])
    ans = 0
    for i in range(n):
        ans += all_lcm//a[i]
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L/a

MOD = 1000000007
print(int(ans)%MOD)

Submission status: Runtime Error

Solution code:
import math
import fractions
n = int(input())


l = list(int ,input().split())

lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]
    ans%=1000000007
print(ans)

Submission status: Runtime Error

Solution code:
import math as m
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
def lcm(x,y):
    return (x*y//m.gcd(x,y))
def lcml(nums):
    return reduce(lcm,nums,1)
l = lcml(a)
for x in a:
    ans+= (l*pow(x,mod-2,mod)) %mod
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = [int(x) for x in input().split()]
g = a[0]
if n>1:
    for idx in range(1,len(a)):
        g = a[idx]*g//math.gcd(a[idx],g)
ans = []
for i in range(n):
    ans.append(int(g/a[i]))
print(sum(ans)%(10**9+7))

Submission status: Runtime Error

Solution code:
import sys
import math
import heapq
import fractions

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()

primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]

INL=LI()
LCM={}
for i in INL:
    for p in primes:
        cnt = 0
        while i%p == 0:
            i //= p
            cnt += 1
        if not p in LCM: LCM[p] = 0
        LCM[p] = max(LCM[p], cnt)
    if i != 1:
        if not i in LCM: LCM[p] = 0
        LCM[i] = max(LCM[i], 1)

res = 0
for i in INL:
    num = 1
    for p, cnt in LCM.items():
        cnt2 = 0
        while i % p == 0:
            i //= p
            cnt2 += 1
        num *= p**(cnt - cnt2)
    res += num

# print(LCM)
print(res%DVSR)

Submission status: Runtime Error

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

a0 = min(a)

def lcm(a):
    x = 1
    for i in a:
        x = (x * i) // gcd(x,i)
    return x

l = lcm(a) // a0

count = 0
for i in a:
    count += int(l*a0/i)
    count = count % (1000000007)
    
print(count)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(50000)

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

mod = 10**9+7

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

def lcm(x, y):
    tmp = modinv(math.gcd(x,y),mod)
    # print(mod)
    return x * y * tmp

l = 1
for k in a:
    l = lcm(l,k)

l = l % mod

mod = 10**9+7
res = 0
for k in a:
    tmp = modinv(k, mod)
    res = (res + l * tmp % mod) % mod

res = res % mod
print(res)

# print(a)

# ans = 1

# if n == 1:
#     print(1)
#     exit
# elif n == 2:
#     l = lcm(a[0], a[1])
#     print(l//a[0]+ l//a[1])
#     exit

# print(10)

# ans = 1
# for i in range(n):
#     tmp = lcm(l, i)
#     ans/(n-1)
#     l = lcm(l, a[i])

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    while b:a,b=a,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l//A[i]
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:

MOD = 1000000007

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

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

def main():
    n = int(input())
    a = list(map(int,input().split()))
    all_lcm = a[0]
    for i in range(n):
        all_lcm = lcm(all_lcm, a[i])
    ans = 0
    for i in range(n):
        ans += all_lcm/a[i]
        ans %= MOD
    print(int(ans))

main()

Submission status: Runtime Error

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

from math import gcd # Python versions 3.5 and above
from functools import reduce # Python version 3.x


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

# def lcm(denominators):
#     return reduce(lambda a,b: a*b // gcd(a,b), denominators)

res = reduce(lcm, A, 1)
# res = lcm(A)
print(sum(res // A[i] for i in range(N)) % (10 ** 9 + 7))

Submission status: Runtime Error

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

def lcm(a):
    x = 1
    for i in a:
        x = (x * i) // gcd(x,i)
        
    return x

l = lcm(a)

count = 0
for i in a:
    count += int(l/i)
    count = count % (1000000007)
    
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions
 
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

def LI():
  return [int(s) for s in input().split()]


input = sys.stdin.readline
ri = lambda: int(input())
ril = lambda: list(map(int, input().split()))

N = ri()
A_s = ril()
mod = 10**9 + 7
 
l = lcm_list(A_s)
 
print(sum(map(lambda x : l//x, A_s)) % mod)

Submission status: Runtime Error

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

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
	lcm %= MOD
ans = 0
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)

print(ans%MOD)

Submission status: Runtime Error

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


def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b/gcd(a,b)

L = 1

D = 1000000007
for i in range(N):
    L = lcm(L,A[i]) 
L = L % D

res = 0
for i in range(N):
    res = (res + L * pow(A[i],D-2,D)) % D  
print(int(res))

Submission status: Runtime Error

Solution code:

import numpy as np
from functools import reduce
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools
import math

def acinput():
    return list(map(int, input().split(" ")))


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import math
MOD = 1000000007

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

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

l = 1
for i in A:
    l = lcm(l, i)

l %= MOD

ans = 0
for i in A:
    ans += l*pow(i, MOD-2, MOD)
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return max(fct)


for i in range(n):
    a[i]=factorize(a[i])

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fractions.gcd(count, a[i+1])
ans=0


for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

a0 = min(a0)

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

l = lcm(a)/a0
count = 0
for i in range(len(a)):
    count += int(l*a0/a[i])
    count = count % (1000000007)
print(count)

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
l = list(map(int,input().split()))

ans = l[0]*l[1]/fractions.gcd(l[0],l[1])
for i in range(2,n):
    ans = ans*l[i]/fractions.gcd(ans,l[i])

mod = 10**9+7
a = 0
for i in range(n):
    a += ans//l[i]
    a %= mod
print(int(a%mod))

Submission status: Runtime Error

Solution code:
import math

n = int(input())
l = []
for i in range(n):
    l[i] = int(input())
lc = 1



for i in range(n):
    lc = math.gcd(lc , l[i])/lc*l[i]

for i in range(n):
    print(lc/l[i])
    print(" ")

Submission status: Runtime Error

Solution code:
from functools import reduce

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

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

def lcm_list(numbers):
    a = lcm(numbers[0], numbers[1])
    for i in range(2, len(numbers)):
        b = numbers[i]
        a = lcm(a, b)
    return a

n = int(input())
l = [int(_) for _ in input().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
    ans %= (10**9 + 7)
print(ans)

Submission status: Runtime Error

Solution code:

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

from math import gcd # Python versions 3.5 and above
from functools import reduce # Python version 3.x

def lcm(denominators):
    return reduce(lambda a,b: a*b // gcd(a,b), denominators)

res = lcm(A)
print(sum(res // A[i] for i in range(N)) % (10 ** 9 + 7))

Submission status: Runtime Error

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

m = sum(b) % mod
print(int(m))

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
    AB = AB*i//fractions.gcd(AB,i)
sumB = 0
for i in A:
    sumB += AB/i
print(int(sumB%(10**9+7)))

Submission status: Runtime Error

Solution code:


import numpy as np
#from functools import reduce
import math

def acinput():
    return list(map(int, input().split(" ")))


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
    AB = AB*i//fractions.gcd(AB,i)
sumB = 0
for i in A:
    sumB += int(AB/i)
print(sumB%(10**9+7))

Submission status: Runtime Error

Solution code:


import numpy as np
#from functools import reduce
#import math

def acinput():
    return list(map(int, input().split(" ")))


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
def s():
  from sys import stdin
  read=stdin.buffer.readline
  n=int(read())
  l=list(map(int,read().split()))
  f=l[0]
  mod=10**9+7
  def gcd(s,d):
    s,d=max(s,d),min(s,d)
    while  d:
      s,d=d,s%d
    return s
  for i in l:
    f=i*f//gcd(i,f)
  ans=0
  for iu in l:
    b,u,v=mod,1,0
    while b:
      t=x//b;x,b=b,x%b;u-=t*v;u,v=v,u
    ans+=(f*u%mod)%mod
    ans%=mod
  print(ans)
  
if __name__=="__main__":s()

Submission status: Runtime Error

Solution code:


import numpy as np
from functools import reduce
#import math

def acinput():
    return list(map(int, input().split(" ")))


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
    AB = (AB*i)//fractions.gcd(AB,i)
sumB = 0
for i in A:
    sumB += int(AB/i)
print(sumB%(10**9+7))

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
A = list(map(int, input().split()))
AB = 1
for i in A:
    AB = (AB*i)//fractions.gcd(AB,i)
sumB = 0
for ii in range(N):
    sumB += int(AB/A[ii])
print(sumB%(10**9+7))

Submission status: Runtime Error

Solution code:
import fractions import gcd
s=int(input())
t=list(map(int, input().split()))
ans=t[0]
for i in t:
  ans=(ans*i)//gcd(ans,i)
mod=10**9+7
ans%=mod
a=0
for j in t:
  a+=ans//j
print(int(a)%mod)

Submission status: Runtime Error

Solution code:
import fractions
N=int(input())
a = list(map(int, input().split()))
gcd = a[0]
for i in range(1, N):
    gcd = gcd * a[i] // fractions.gcd(gcd, a[i])

b= []
for i in range(N):
    b.append(gcd //a[i])
ans=0

if N%2==0:
    for i in range(0,N,2):
	    ans = (b[i]+b[i-1])%1000000007
else:
        b.append(0)
	for i in range(0,N,2):
		ans = (b[i]+b[i-1])%1000000007


print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

n = int(input())
tl = input().split()
l = [int(i) for i in tl]


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


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


lcm = lcm_list(l)

ans_list = [lcm/i for i in l]

ans = 0
for i in ans_list:
    ans = int((int(ans % (1000000007)) + int(i % (1000000007))) % (1000000007))

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# E
import numpy as np
N = int(input()) 
A = list(map(int, input().split()))

lcm = np.lcm.reduce(A)

ans = 0
for i in A:
    ans += (lcm//i) % (10**9+7)

print(ans % (10**9+7))

Submission status: Runtime Error

Solution code:


import numpy as np
from functools import reduce
#import math

def acinput():
    return list(map(int, input().split(" ")))


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
def func(x,y):
    return (x*y)//fractions.gcd(x,y)
AB = reduce(func, A, 1)
sumB = 0
for ii in range(N):
    sumB += AB/A[ii]
print(int(sumB%(10**9+7)))

Submission status: Runtime Error

Solution code:
# E
import math
N = int(input()) 
A = list(map(int, input().split()))

lcm = np.lcm.reduce(A)

ans = 0
for i in A:
    ans += (lcm//i) % (10**9+7)

print(ans % (10**9+7))