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 functools
from fractions import gcd

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

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

def divide(number_a, number_b):
    return number_a / number_b

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

lcm = lcm_list(As)

divide_parted = functools.partial(divide, lcm)

divided_list = list(map(divide_parted, As))
result = 0

for d in divided_list:
  result += d
  if result >= 1000000007:
    result = result % 1000000007
    
print(int(result))

Submission status: Runtime Error

Solution code:
import math

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

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

X = 1

for i in range(N):
    X = lcm(X,A[i])

ANS = int(0)

for i in range(N):
    ANS += X//A[i]
    ANS %= int(1000000007)

print(int(ANS))

Submission status: Runtime Error

Solution code:
import functools
from fractions import gcd

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

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

def divide(number_a, number_b):
    return number_a / number_b

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

lcm = lcm_list(As)

divide_parted = functools.partial(divide, lcm)

divided_list = list(map(divide_parted, As))
result = 0
for d in divided_list:
  result += d
  if result > 1000000007:
    result = result % 1000000007
    
print(int(result))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
k=reduce(lambda x,y:x*y//gcd(x,y),a)
ans=sum(list(map(lambda x:k//x,a)))
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
k=reduce(lambda x,y:x*y//gcd(x,y),a)
ans=sum(list(map(lambda x:k//x,a)))
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())

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

list = sorted(ai)
#print(list)

kobaisuu = list[-1]

for j in range(N):
    amari = kobaisuu % list[-j]
    if (amari != 0):
        kobaisuu *= list[-j]

#print(kobaisuu)
bi = [0]*N

for k in range(N):
    bi[k] = kobaisuu/ai[k]

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

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

B = np.array([])
for i in range(N):
    B = np.append(B,lcm_a//A[i])

mod = int(1e9+7)
print(int((np.sum(B)%mod)))

from fractions import gcd

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
C=10**9+7
def gc(a,b):
  ma=max(a,b)
  mi=min(a,b)
  while mi>0:
    nex_ma=mi
    mi=ma%mi
    ma=nex_ma
  return ma
def lc(a,b):
  g=gc(a,b)
  return a*b//g
lca=l[0]
for i in range(1,N):
  lca=lc(lca,l[i])
ans=0
for i in range(N):
  ans+=(l[i]//lca)
  ans=ans%C
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    import fractions
    n = int(input())
    array = list(map(int, input().split()))
    lcm = array[0]
    for i in range(1, n):
        lcm = lcm * array[i] // fractions.gcd(lcm, array[i])

    total = 0
    for i,num in enumerate(array):
        total += lcm / num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#２つでの再酥油公倍数
def lcm_base(x, y):
    from fractions import gcd
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    from functools import reduce
    return reduce(lcm_base, numbers, 1)


def main():
    n = int(input())
    array = list(map(int, input().split()))
    lcm = lcm_list(array)

    total = 0
    for i,num in enumerate(array):
        total += lcm / num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd # for python3.4 or lower
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)
 
 
def main():
    n = int(input())
    array = list(map(int, input().split()))
    lcm = lcm_list(array)
 
    total = 0
    for i,num in enumerate(array):
        total += lcm / num
    print(int(total%(10**9+7)))
 
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#２つでの再酥油公倍数
def lcm_base(x, y):
    import math
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    from functools import reduce
    return reduce(lcm_base, numbers, 1)


def main():
    n = int(input())
    array = list(map(int, input().split()))
    lcm = lcm_list(array)

    total = 0
    for i,num in enumerate(array):
        total += lcm / num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

#２つでの再酥油公倍数
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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


def main():
    n = int(input())
    array = list(map(int, input().split()))
    lcm = lcm_list(array)

    total = 0
    for i,num in enumerate(array):
        total += lcm / num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
from fractions import gcd

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


def main():
    x = 1
    ans = 0
    for a in A:
        tmp = gcd(x, a)
        # ans += (i) * A[i] // tmp + A[i] * x //tmp  
        x = (x * a) // tmp
    
    b = 0
    A = np.array(A)
    # for a in A:
    #     b += x // a
    b = np.sum(x//a)
        
    print(b%MOD)
main()

Submission status: Runtime Error

Solution code:
import numpy as np
from fractions import gcd

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

x = 1
ans = 0
for a in range(A):
    tmp = gcd(x, a)
    # ans += (i) * A[i] // tmp + A[i] * x //tmp  
    x = (x * a) // tmp
    
b = 0
for a in range(A):
    b += x // a
    
print(b%MOD)

Submission status: Runtime Error

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

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        primes[a] = 1

lcm = 1
for p in primes.value():
    lcm *= pow(p, primes[p], MOD) % MOD

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

print(ans)

Submission status: Runtime Error

Solution code:
import collections

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

mod = 10**9+7

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(10**3)

def primeFactorization(n):
    ans = []
    temp = n
    for p in primes:
        while temp%p == 0:
            ans.append(p)
            temp /= p
    if temp > 1:
        ans.append(temp)
    return collections.Counter(ans)

AFactorized = list(map(primeFactorization, A))

lcm = collections.Counter()
for a in AFactorized:
    for p, n in a.items():
        lcm[p] = max(lcm[p], n)

lcm_val = 1
for p, n in lcm.items():
    lcm_val *= pow(p, n, mod)

ans = 0
for a in A:
    ans += lcm_val * pow(a, mod-2, mod)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", b: "List[int]", M: int, u: "List[int]", v: "List[int]"):
    conns = [[] for _ in range(N)]
    for i in range(N - 1):
        conns[a[i] - 1].append((b[i] - 1, i))
        conns[b[i] - 1].append((a[i] - 1, i))
    bits = []
    def dfs(idx, t, visited):
        visited[idx] = True
        if idx == t:
            return 0
        for node, edge_idx in conns[idx]:
            if not visited[node]:
                tmp = dfs(node, t, visited)
                if tmp is not None:
                    return tmp + (1 << edge_idx)
        return None
    for j in range(M):
        visited = [False] * N
        bit = dfs(u[j] - 1, v[j] - 1, visited)
        bits.append(bit)

    ret = 0
    for i in range(2 ** (N - 1)):
        for j in range(M):
            if i & bits[j] == 0:
                break
        else:
            ret += 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N - 1)  # type: "List[int]"
    b = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    M = int(next(tokens))  # type: int
    u = [int()] * (M)  # type: "List[int]"
    v = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, a, b, M, u, v)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import collections

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

mod = 10**9+7

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(10**3)

def primeFactorization(n):
  ans = []
  temp = n
  for p in primes:
    while temp%p == 0:
      ans.append(p)
      temp /= p
  if temp > 1:
    ans.append(temp)
  return collections.Counter(ans)

AFactorized = list(map(primeFactorization, A))

lcm = collections.Counter()
for a in AFactorized:
    for p, n in a.items():
        if n > lcm.get(p, 0):
            lcm[p] = n

lcm_val = 1
for p, n in lcm.items():
    lcm_val *= pow(p, n, mod)

ans = 0
for a in A:
    ans += lcm_val * pow(a, mod-2, mod)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=1
    for i in l:
        lcm=(lcm*i)//gcd(lcm,i)
    ans=0
    mod=1000000007
    for i in l:
        ans=(ans+(lcm//i))%mod
    print(ans)

if __name__ == "__main__":
    dp()

Submission status: Runtime Error

Solution code:
def main():
    from fractions import gcd

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

    l = 1
    for num in num_list:
        l *= num // gcd(l, num)

    answer = 0
    for num in num_list:
        answer += l // num
        answer %= 1e9 + 7

    print(int(answer))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from franctions import gcd

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num//i
  ans %= 1000000007
  
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
N=int(input())
A=list(map(int,input().split()))
a=A[0]
for i in range(1,len(A)):
    a=int(a*A[i]/fractions.gcd(a,A[i]))
x=0
for i in range(len(A)):
    A[i]=int(a/A[i])
    if x<10**9+7:
        x=x+A[i]
    else:
        x=(x+A[i])%(10**9+7)
    
print(x%(10**9+7))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 22 13:08:59 2020

@author: USER
"""
import fractions
N=int(input())
A=list(map(int,input().split()))
a=A[0]
for i in range(1,len(A)):
    a=int(a*A[i]/fractions.gcd(a,A[i]))
x=0
for i in range(len(A)):
    A[i]=int(a/A[i])
    x=x+A[i]/(10**9+7)
print(x%(10**9+7))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)
def gcd(x,y):
  if y==0:
      return x
  return gcd(y,x%y)
def lcm(x,y):
    return x/gcd(x,y)*y

n = int(input())
a = list(map(int,input().split()))
LCM=a[0]
for i in a:
  LCM = lcm(LCM,i)
ans=0
for i in a:
  ans += LCM/i
  ans %= 1000000007
  
print(int(ans))

Submission status: Runtime Error

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

n = int(input())
a = list(map(int,input().split()))
LCM=a[0]
for i in a:
  LCM = lcm(LCM,i)
ans=0
for i in a:
  ans += LCM/i
  ans %= 1000000007
  
print(int(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 22 13:08:59 2020

@author: USER
"""
import fractions
N=int(input())
A=list(map(int,input().split()))
a=A[0]
for i in range(1,len(A)):
    a=int(a*A[i]/fractions.gcd(a,A[i]))
x=0
for i in range(len(A)):
    A[i]=int(a/A[i])
    x=x+A[i]
print(x%(10**9+7))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  r = a%b
  while r > 0:
    a=b
    b=r
    r=a%b
  return b

n = int(input())
A = list(map(int,input().split()))
num = 1
ans = 0
for i in A:
  num = i // gcd(i,num) * num

for i in A:
  ans += num/i
  ans %= 1000000007
  
print(int(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 22 13:08:59 2020

@author: USER
"""
import math
N=int(input())
A=list(map(int,input().split()))
a=A[0]
for i in range(1,len(A)):
    a=int(a*A[i]/math.gcd(a,A[i]))
x=0
for i in range(len(A)):
    A[i]=int(a/A[i])
    x=x+A[i]
print(x%(10**9+7))

Submission status: Runtime Error

Solution code:
from math import gcd

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

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

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

ans = 0
for i in a:
    ans += l // i

print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
from fractions import gcd

d = int(input())
nums = list(map(int, input().split(' ')))

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


lcm_num = 1
for i in range(len(nums)):
  lcm_num = lcm_base(lcm_num, nums[i])

ans = 0
for n in nums:
  ans += int(lcm_num / n)
print(ans % (10**9 + 7))

Submission status: Runtime Error

Solution code:
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
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

ans=0
LCM=1
for i in range(n):
    LCM=lcm(LCM,A[i])

for a in A:
    ans += (LCM / a) % mod
    
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
n_nums = int(input())
nums = tuple(map(int, input().split()))
ans = nums[0]
for num in nums:
    ans = ans * num // fractions.gcd(ans, num)
 
print(int(sum(ans/num for num in nums))%(10**9 + 7))

Submission status: Runtime Error

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

print(int(sum(ans/num for num in nums)))

Submission status: Runtime Error

Solution code:
from fractions import gcd  # python<=3.4

MOD=1000000007

n = int(input().rstrip())
a = [int(x) for x in input().rstrip().split()]

el = 1
for ai in a:
  g = gcd(a,b)
  el = el // g * b

sum = 0
for ai in a:
    sum = (sum + el // ai) % MOD

print(sum)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000000)


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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) // gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek // a[i]
print(int(s % mod))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000000)


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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) // gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))

Submission status: Runtime Error

Solution code:
import sys
MOD = 10**9+7

n = int(input())
A = list(map(int, input().split()))
prmMax = int(pow(max(A), 0.5))+1
Prm = [ [0]*prmMax for _ in range(n) ]

def keepAsPrime(x, List):
    for i in range(1, int(pow(x, 1/2))+2):
        if x%i == 0:
            List[i] += 1

for i in range(n):
    keepAsPrime(A[i], Prm[i])
print(Prm)
Lcm = [ max(Prm[:][i]) for i in range(1, prmMax+1) ]
print(Lcm)
ans = 0
for a in A:
    ans = ans+lcm//a
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import math

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

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

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

now_lcm = a[0]
for i in range(n-1):
    now_lcm = lcm(now_lcm,a[i+1])

mod = 1e9+7
ans = 0
for e in a:
    ans = ((ans%mod) + ((now_lcm//e)%mod))%mod

print(int(ans))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000000)


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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000000)


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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000000)


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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))

Submission status: Runtime Error

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


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))

Submission status: Runtime Error

Solution code:
n = int(input())
nums = list(map(int,input().split(" ")))
def gcdd(x,y):
    if x < y:
        x,y = y,x
    while(y): 
       x, y = y, x % y 
    return x

def findLCM(num1,num2):
    gcdRes = gcdd(num1, num2)
    return int(num1 * num2/gcdRes)

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += int(lcm/num) % mod
print(res % mod)

Submission status: Runtime Error

Solution code:
n = int(input())
nums = list(map(int,input().split(" ")))
def gcd(x,y):
    if x < y:
        x,y = y,x
    while(y): 
       x, y = y, x % y 
    return x

def findLCM(num1,num2):
    gcdRes = gcd(num1, num2)
    return int(num1 * num2/gcdRes)

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += int(lcm/num) % mod
print(res % mod)

Submission status: Runtime Error

Solution code:
n = int(input())
nums = list(map(int,input().split(" ")))
def gcd(x,y):
    if x < y:
        x,y = y,x
    while(y): 
       x, y = y, x % y 
    return x

def findLCM(num1,num2):
    gcdRes = gcd(num1, num2)
    return int(num1 * num2/gcdRes)

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += int(lcm/num % mod)
print(res % mod)

Submission status: Runtime Error

Solution code:
n = int(input())
nums = list(map(int,input().split(" ")))
def gcd(x,y):
    while(y): 
       x, y = y, x % y 
    return x

def findLCM(num1,num2):
    gcdRes = gcd(num1, num2)
    return int(num1 * num2/gcdRes)

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += int(lcm/num % mod)
print(res % mod)

Submission status: Runtime Error

Solution code:
n = int(input())
nums = list(map(int,input().split(" ")))
def gcd(x,y):
    while(y): 
       x, y = y, x % y 
    return x

def findLCM(num1,num2):
    gcdRes = gcd(num1, num2)
    return int(num1 * num2/gcdRes)

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += int(lcm/num % mod)
print(res % mod)

Submission status: Runtime Error

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

gcdRes = nums[0]
prod = nums[0]

def findLCM(num1,num2):
    gcdRes = math.gcd(num1, num2)
    return int(num1 * num2/gcdRes)

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += int(lcm/num % mod)
print(res % mod)

Submission status: Runtime Error

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

gcdRes = nums[0]
prod = nums[0]

def findLCM(num1,num2):
    gcdRes = math.gcd(num1, num2)
    return num1 * num2 // gcdRes

mod = 10**9+7

lcm = findLCM(nums[0],nums[1])

for i in range(2, len(nums)): 
    lcm = findLCM(lcm, nums[i])

res = 0
for num in nums:
    res += lcm // num % mod
print(res % mod)

Submission status: Runtime Error

Solution code:
# abc 152 e
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

N = int(readline().rstrip())
al = list(map(int, readline().split()))

# 最大公約数
from fractions import gcd

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

lcm_ = 0
for a in al:
    if lcm_ == 0:
        lcm_ = a
        continue
    lcm_ = lcm(a, lcm_)

prime = 10 ** 9 + 7
bl = []
for a in al:
    b = int(lcm_ / a)
    bl.append(b)

answer = sum(bl) % prime
print(answer)

Submission status: Runtime Error

Solution code:
# abc 152 e
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

N = int(readline().rstrip())
al = list(map(int, readline().split()))

# 最大公約数
from fractions import gcd

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

lcm_ = 0
for a in al:
    if lcm_ == 0:
        lcm_ = a
        continue
    lcm_ = lcm(a, lcm_)

prime = 10 ** 9 + 7
bl = []
for a in al:
    b = int(lcm_ / a)
    bl.append(b)

answer = sum(bl)
print(answer)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def lcm_base(x, y):
    return math.floor((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)

if __name__ =="__main__":
    N = int(input())
    A = list(map(int, input().split()))
    LCM = lcm_list(A)
    sum = 0
    for a in A:
        sum += math.floor(LCM/a)
        sum %= 10**9 + 7

    print(sum)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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())
A = list(map(int, input().split()))

LCM = lcm_list(A)
sum = 0
for i in range(N):
    sum += LCM/A[i]
    sum %= 10**9 + 7

print(sum)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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())
A = list(map(int, input().split()))

LCM = lcm_list(A)
sum = 0
for i in range(N):
    sum += LCM//A[i]
    sum %= 10**9 + 7

print(sum)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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())
A = list(map(int, input().rstrip().split() ) )

LCM = lcm_list(A)
sum = 0
for i in range(N):
    sum += LCM//A[i]
    sum %= 10**9 + 7

print(sum)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

m = A[0]
for i in range(1,N):
    lm = lm*A[i] // gcd(lm,A[i])

ans = 0

for i in range(N):
    ans += ( lm//A[i] )
    ans %= Mod

print(ans)

Submission status: Runtime Error

Solution code:
# エラトステネスの篩, フェルマーの小定理
from math import sqrt


def mpow(x, n):
    result = 1
    while n != 0:
        if n & 1 == 1:
            result *= x
            result %= 1000000007
        x *= x
        x %= 1000000007
        n >>= 1
    return result


max_A = 1000000

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

sieve = [0] * (max_A + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, int(sqrt(max_A)) + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, max_A + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

lcm_factors = {}
for i in range(N):
    t = []
    a = A[i]
    while a != 1:
        if len(t) != 0 and t[-1][0] == sieve[a]:
            t[-1][1] += 1
        else:
            t.append([sieve[a], 1])
        a //= sieve[a]
    for k, v in t:
        if k not in lcm_factors or lcm_factors[k] < v:
            lcm_factors[k] = v

lcm = 1
for k in lcm_factors:
    for i in range(lcm_factors[k]):
        lcm *= k
        lcm %= 1000000007

result = 0
for i in range(N):
    result += lcm * mpow(A[i], 1000000007-2)
    result %= 1000000007
print(result)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000100)

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

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

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

if N == 1:
    lcmAll = A[0]
elif N == 2:
    lcmAll = lcm(A[0], A[1])
else:
    for i in range(2, N):
        lcmAll = lcm(lcmAll, A[i])

BIG_PRIME = 1000000007
ans = 0
for i in range(N):
    d = lcmAll // A[i]
    d %= BIG_PRIME
    ans += d
    ans %= BIG_PRIME

print(str(ans))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000100)

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

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

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

lcmAll = lcm(A[0], A[1])
if N > 2:
    for i in range(2, N):
        lcmAll = lcm(lcmAll, A[i])

BIG_PRIME = 1000000007
ans = 0
for i in range(N):
    d = lcmAll // A[i]
    d %= BIG_PRIME
    ans += d
    ans %= BIG_PRIME

print(str(ans))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(60000)

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

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

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

lcmAll = lcm(A[0], A[1])
if N > 2:
    for i in range(2, N):
        lcmAll = lcm(lcmAll, A[i])

BIG_PRIME = 1000000007
ans = 0
for i in range(N):
    d = lcmAll // A[i]
    d %= BIG_PRIME
    ans += d
    ans %= BIG_PRIME

print(str(ans))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(30000)

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

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

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

lcmAll = lcm(A[0], A[1])
if N > 2:
    for i in range(2, N):
        lcmAll = lcm(lcmAll, A[i])

BIG_PRIME = 1000000007
ans = 0
for i in range(N):
    d = lcmAll // A[i]
    d %= BIG_PRIME
    ans += d
    ans %= BIG_PRIME

print(str(ans))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if a==0:return b
    return gcd(b%a,a)
n = int(input())
a = list(map(int, input().split()))
#print(a)
b=[]
for i in range(n):
    #print(i)
    b.append(a[i])
for i in range(n):
    if i != 0:
        b[i]=int(b[i-1]/int(gcd(b[i-1],b[i])))*b[i]
lcm=b[n-1]
ans=0
for i in range(n):
    #print(a[i])
    ans=(ans+lcm/a[i])
M = 10**9+7
print(int(ans%M))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  if a==0:return b
  return gcd(b%a,a)
n = int(input())
a = list(map(int, input().split()))
#print(a)
b=[]
for i in range(n):
    #print(i)
    b.append(a[i])
for i in range(n):
    if i != 0:
        b[i]=int(b[i-1]/int(gcd(b[i-1],b[i])))*b[i]
lcm=b[n-1]
ans=0
for i in range(n):
    #print(a[i])
    ans=(ans+lcm/a[i])
print(int(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
  if a==0:return b
  return gcd(b%a,a)
n = int(input())
a = list(map(int, input().split()))
#print(a)
b=[]
for i in range(n):
    #print(i)
    b.append(a[i])
for i in range(n):
    if i != 0:
        b[i]=int(b[i-1]/int(gcd(b[i-1],b[i])))*b[i]
lcm=b[n-1]
ans=0
for i in range(n):
    #print(a[i])
    ans=(ans+lcm/a[i])%(10**9+7)
print(int(ans))

Submission status: Runtime Error

Solution code:
import math

n = int(input())
arr = input()   # takes the whole line of n numbers
a = list(map(int,arr.split(' ')))

lcm=1

for i in range(n):
	lcm=lcm*a[i]//math.gcd(lcm,a[i])
  
final=0;

for i in range(n):
	final=final+lcm//a[i]
  
print(final%1000000007)

Submission status: Runtime Error

Solution code:
n=int(intput())
arr=input()

a=list(map(int,arr.split(' ')))

lcm =a[0]

for i in range(1,n-1)
	lcm=lcm*a[i]//math.gcd(lcm*a[i])
  
final=0;

for i in range(n)
	final=final+lcm//a[i]
  
print(final)