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 math
def _lcm(a, b):
    return a // math.gcd(a, b) * b
n = int(input())
arr = [int(i) for i in input().split()]
lcm = 1
for x in arr:
    lcm = _lcm(lcm, x)
s = 0
mod = int(1e9 + 7)
for x in arr:
    s += lcm // x
    s %= mod
print(s)

Submission status: Runtime Error

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

n=int(input())
aa=[]*n
aa=list(map(int,input().split()))

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

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 int(a * b / gcd(a, b))

# Aの最小公倍数を求める
a_lcm = A[0]
for i in range(1, N):
    a_lcm = lcm(a_lcm, A[i])

# Bを数え上げる
b_sum = 0
for a in A:
    b_sum += int(a_lcm / a)

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

Submission status: Runtime Error

Solution code:
import math

MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
u = set(a)
if len(u) == 1:
    print(n)
    exit()
else:
    g = 1
    for x in u:
        g = g * x // math.gcd(g, x)
    b = 0
    for i in range(n):
        b = b + (g // a[i])
print(b%MOD)

Submission status: Runtime Error

Solution code:
mod = 1e9 + 7;

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

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

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

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

print(int(sum))

Submission status: Runtime Error

Solution code:
from math import gcd
n = int(input())
a = [int(i) for i in input().split()]

lcm = a[0]
for i in range(1, n):
    lcm = (lcm * a[i]) // gcd(lcm, a[i])
ans = 0
mod = 1000000007

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

Submission status: Runtime Error

Solution code:
n = int(input())

l = [int(num) for num in input().split()]


def find_lcm(num1, num2):
    if(num1 > num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm


num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])

result = 0

for i in l:
    s = lcm / i
    result += s

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

print(int(result))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

    v = lcm(A)
    S = 0
    for i in range(N):
        S += v // A[i]

    print(round(S % (1e9 + 7)))

main()

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

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)
  
n = int(input())
box = list(map(int, input().split()))
min_max = lcm_list(box)
b = []
for i in range(n):
  b.append(min_max/box[i])
  
print(int(sum(b)%(1000000000+7)))

Submission status: Runtime Error

Solution code:
from functools import reduce
from fractions import gcd

n = int(input())
As = list(map(int, input().split()))
mod = 10**9 + 7
def lcm(l):
    if len(l) == 2:
        return l[1]*l[0] // gcd(l[1], l[0])
    else:
        k = lcm(l[:-1])
        return k*l[-1] // gcd(k, l[-1])

k = lcm(As)
ans = 0
for i in range(n):
    ans += k // As[i]
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
import fractions


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


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

lcm_pre = lcm(a[0], a[1])
lcm_current = lcm_pre
ans = lcm_current // a[0]
ans += lcm_current // a[1]

if n == 1:
    print(a[0] % mod)
    exit()
elif n == 2:
    print(ans % mod)
    exit()

for i in range(2, n):
    lcm_current = lcm(lcm_pre, a[i])
    if lcm_current != lcm_pre:
        ans *= lcm_current // lcm_pre
        lcm_pre = lcm_current
    ans += lcm_current // a[i]
    ans %= mod
print(ans % mod)

Submission status: Runtime Error

Solution code:
def computeGCD(x, y):
   while(y):
       x, y = y, x % y
   return x


def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = {}
    def lcm(x, y):
        if x > y:
             x, y = y, x
        key = (x, y)
        if key in m:
            return m[res]
        res = x * y // computeGCD(x, y)
        m[key] = res
        return res
 
    def rec(ls):
        if len(ls) == 1:
            return ls[0]
        elif len(ls) == 2:
            return lcm(ls[0], ls[1])
        return lcm(rec(ls[:len(ls) // 2]), rec(ls[len(ls) // 2:]))
    l = rec(a)
    ans = 0
    for i in range(n):
        ans += l // a[i]
        ans %= 10**9 + 7
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from functools import reduce
import math
def lcm(x,y):return x*y//math.gcd(x,y)
def lcmm(l):return reduce(lcm,l)
a=int(input())
b=list(map(int,input().split()))
num=0
c=lcmm(b)
for i in range(a):
    num+=int(c/b[i])
print(int(num%(10**9+7)))

Submission status: Runtime Error

Solution code:
mod = 1000000007
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def add(a, b):
    return (a + b) % mod
import fractions
def gcds(a):
  ans = a[0]
  for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
  return ans
n=int(input())
c=list(map(int,input().split()))
gc = 1
for i in c:
	gc = mul(gc,i)
gc = gcds(c)
s = 0
for i in c:
  s = add(s,gc/i)
print(int(s))

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(raw_input())
arr = raw_input()
a = list(map(int,arr.split(' ')))

lcm = a[0]
for i in a[1:]:
  lcm = lcm*i//gcd(lcm, i)
ans=0
mod=1000000007
for i in a[0:]:
  ans=ans+(lcm/i)
  ans=ans%mod
ans=ans%mod
print(int(ans))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x % MOD
B = np.array(A[1:])
answer += ((first * x // B) % MOD).sum()

print(answer%MOD)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // 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())
box = list(map(int, input().split()))
min_max = lcm_list(box)
b = []
for i in range(n):
  b.append(min_max/box[i])
  
print(int(sum(b)%(1000000000+7)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

total=0  
for i in range(0,N):
  if total+ ans/a[i] >= 10**9+7:
    total = (total+ans/a[i])%(10**9+7)
  else:
    total+= ans/a[i]
  
  
  
print(int(total))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
li = list(map(int,input().split()))
lcm = np.lcm.reduce(li)

res = list(map(lambda x:lcm//x,li))
print(sum(res)%(10^9+7))

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

read = sys.stdin.read


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


def sieve_of_eratosthenes(n):
    sieve = [True] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


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

primes = sieve_of_eratosthenes(max(A))
dic = {i: 0 for i in primes}

n = len(primes)
p = [0] * n
for i in A:
    tmp = Counter(prime_factorize(i))
    for key, value in tmp.items():
        #print(key, value)
        if dic[key] < value:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    if j == 0:
        continue
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
a = []
lcm = 1
for i in range(n):
  t = int(input())
  a.append(t)
  
lc = np.lcm.reduce(a)

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

print(res)

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 get_lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

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

def inverse_sum(list,lcm):
    sum = 0
    for a in list:
        sum += int(lcm/a)
    return sum
def inverse_sum2(list):
    sum = 0
    for a in list:
        sum += lcm/a
    return sum

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

lcm = lcm_list(A)


ans = inverse_sum(A,lcm )
#print(ans)
ans = ans % (10e9 + 7)

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

res = 1e9 + 7

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

def lcm_base(x, y):
    return (x * y) // 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())
As = list(map(int, input().split()))


lcm_num = lcm_list(As)

sum = 0

for i in range(N):
  sum += int((lcm_num / As[i]) % res)

print(int(sum % res))

Submission status: Runtime Error

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

def lcm(a, b):
    return a * b // gcd (a, b)
  
n = int(input())
a = list(map(int,input().split()))

l = a[0]

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

c = 0  
for i in range(n):
  c += int(l / a[i])
  
print(c)

Submission status: Runtime Error

Solution code:
a = int (input ())
ll = [int (x) for x in input ().split (' ')]
import math
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
lmczao = 1
for i in ll:
    lmczao = lcm (lmczao, i)
sum = 0
for i in ll:
    sum = (sum + lmczao // i) % 1000000007
print (int (sum))

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

kobai=1

for a in a_list:
    kobai = int(lcm(kobai,a))

sumN=0
for i in a_list:
    sumN+=int(kobai/i)

#sumN=int(sumN%(1e9+7))
   

print(sumN)

Submission status: Runtime Error

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

lcm = a[0]
for i in a[1:]:
  lcm = lcm*i//gcd(lcm, i)
ans=0
mod=1000000007
for i in a[0:]:
  ans=ans+(lcm/i)
  ans=ans%mod
ans=ans%mod
print(int(ans))

Submission status: Runtime Error

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

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

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


l = [ans for _ in range(N)]
l = np.array(l)/A
print(int(l.sum()%(10**9+7)))

Submission status: Runtime Error

Solution code:
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)

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

common=lcm_list(A)
ans=0
for i in range(N):
    ans+=A[i]**(-1)
print(int(common*ans)%a)

Submission status: Runtime Error

Solution code:
N=int(input())
import fractions
a = list(map(int, input().split()))
S=a[0]
for i in range(1,N):
  S=S*a[i]
b=[0 for z in range(N)]
for i in range(N):
  b[i]=S/a[i]
ans = b[0]
for i in range(1, N):
    ans = fractions.gcd(ans, b[i])
S=0
M=10**9+7
for i in range(N):
  S=(S+b[i]/ans)%M
print(int(S%M))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

P = 10**9 + 7
N = 10000
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

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

#kyodai=lcm_list(A)
kyodai=A[0]
for i in range(1,n):
    kyodai=lcm_base(kyodai,A[i])

ans=0

for i in range(n):
    ans+=kyodai*inv_t[A[i]]
    ans=ans%P

print(ans)

Submission status: Runtime Error

Solution code:
import fractions


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


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

lcm_pre = lcm(a[0], a[1])
lcm_current = lcm_pre
ans = lcm_current // a[0]
ans += lcm_current // a[1]

if n == 1:
    print(a[0] % mod)
    exit()
elif n == 2:
    print(ans % mod)
    exit()

for i in range(2, n):
    lcm_current = lcm(lcm_pre, a[i])
    if lcm_current != lcm_pre:
        ans *= lcm_current // lcm_pre
    ans += lcm_current // a[i]
print(ans % mod)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
B = [i for i in range(N)]
MOD = 10 ** 9 + 7
def lcm(a,b):
    return a * b // gcd(a, b)
h = reduce(lcm, A)

for i in range(N):
    B[i] = (h // A[i] % MOD)

print(sum(B) % MOD)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

# 最小公倍数の算出
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

koubai = lcm(A)
B = list(map(lambda x:koubai/x, A))

for b in B:
  res += b % (10**9+7)
  res = res % (10**9+7)

print(int(res))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
l = lcm(A)
ans = 0
for a in A:
    ans += int(l/a)%mod
    ans %= mod
print(ans%mod)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

mod = 10**9 + 7

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


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

ans = reduce(lcm, A)

B = [ans//i for i in A]

print(sum(B) % mod)

Submission status: Runtime Error

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

N = int(input())
A = [int(i) for i in input().split()]
lc = A[0]
for i in range(1, N):
    lc = lcm(lc, A[i])

mod = 10 ** 9 + 7
s = 0
for i in range(N):
    s = (s + lc // A[i]) % mod

print(s)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l = A[0]
for i in range(1,N):
    l = lcm(l,A[i])
print(l)
"""
c = 0
for i in range(N):
    c += l//A[i]%1000000007
print(c%1000000007)
"""

Submission status: Runtime Error

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


for i in range(N):
    ans += int(ss // a[i]) % mod
    ans %= mod

print(int(ans))

Submission status: Runtime Error

Solution code:
a = int (input ())
ll = []
for i in range (0, a):
    ll.append (int (input ()))
import math
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
lmczao = 1
for i in ll:
    lmczao = lcm (lmczao, i)
sum = 0
for i in ll:
    sum = (sum + lmczao // i) % 1000000007
print (int (sum))

Submission status: Runtime Error

Solution code:
import math

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

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

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

ans = 0
for i in range(n):
	ans += (num//a[i]) % 1000000007
	if ans > 1000000007:
		ans = ans%1000000007

print(ans)

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

kobai=1

for a in a_list:
    kobai = int(lcm(kobai,a))

#sumN=0
#for i in a_list:
#    sumN+=int(kobai/i)
#   
#sumN=int(sumN%(1e9+7))

print(sumN)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
M = 10**9+7
n = int(input())
a = tuple(map(int, input().split()))

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

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


a_lcm = lcm(*a)
ans = 0

for i in range(n):
    ans += (a_lcm // a[i])%=M
    ans %= M

print(ans)

Submission status: Runtime Error

Solution code:
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)

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

mmod = int(1e9+7)
alcm = lcm(*a)

sum = 0
for i in range(0,n):
    sum = sum + alcm/a[i]

print(int(sum % mmod))

Submission status: Runtime Error

Solution code:
from fractions import gcd


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

lcm = A[0]

for a in A:
    lcm = (lcm * a) // gcd(lcm, a)

ans = 0
for a in A:
    ans += lcm // a
    ans %= MOD

print(ans)

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()))
    g = a[0]
    MOD = 10**9+7
    for i in range(1,N):
        t = a[i]
        #g = g*a[i]//fractions.gcd(g,a[i])
        g = divmod(g*t,fractions.gcd(g,t))[0]
    assert()
    res = 0
    for i in range(N):
        res += divmod(g,a[i])[1]
        res += (g//a[i])%MOD
    print(res%MOD)
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

output = 0
for i in range(N):
    output += int(X/A[i])%(10**9+7)
    if output > 10**9+7:
        output = output % (10**9+7)
print(output)

Submission status: Runtime Error

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

l = list(map(int,input().split()))
a=1
for i in l:
    a = a*i//math.gcd(a,i)
ans=0
for i in range(n):
    ans=(ans+a//l[i])%1000000007
print(ans)

Submission status: Runtime Error

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

import numpy as np

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

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i])
an = 0
MOD = 10**9+7

for x in A:
  //print(g,g//x)
  an += g//x
  an %= MOD

print(an)

Submission status: Runtime Error

Solution code:
import math
import fractions
from functools import reduce

res = 1e9 + 7

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)

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


lcm_num = lcm_list(As)

sum = 0

for i in range(N):
  sum += int((lcm_num / As[i]) % res)

print(int(sum % res))

Submission status: Runtime Error

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

if N == 1:
  print(1)
  exit()
 
num_lcm = A[0]
for i in range(1, N):
    num_lcm = num_lcm * A[i] // math.gcd(num_lcm, A[i])
 
ans = 0
for a in A:
    ans += num_lcm//a
print(ans%1000000007)

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)

P = 10**9 + 7
N = 10000
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

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

#kyodai=lcm_list(A)
kyodai=A[0]
for i in range(1,n):
    kyodai=lcm_base(kyodai,A[i])

ans=0

for i in range(n):
    ans+=kyodai*inv_t[A[i]]
    ans=ans%P

print(ans)

Submission status: Runtime Error

Solution code:
import fractions

MOD = 1e9 + 7

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

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

lcd_b = A[0]
for a in A:
    lcd_b = (lcd_b * a) // fractions.gcd(lcd_b, a)

ans = 0
for a in A:
    ans += lcd_b / a
    ans %= MOD
print(int(ans))

Submission status: Runtime Error

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n = int(input())
    p = list(map(int,input().split()))
    a = gcd(p[0],p[1])
    lcm = p[0]*p[1]//a
    for i in range(1,n):
        a = gcd(lcm,p[i])
        lcm = lcm*p[i]//a
    anslist = []
    for i in p:
        anslist.append(lcm//i)
    print(sum(anslist)%Mod)

if __name__ == "__main__":
    main() #endline===============================================

Submission status: Runtime Error

Solution code:
import math

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

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

res = 0
divisor = 10 ** 9 + 7
for a in A:
    res += (lcm // a)
    res %= divisor

print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

lcm = lcm(list_A)
list_B = lcm/list_A
print(sum(list_B))

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:
a = int (input ())
ll = []
for i in range (0, a):
  ll.append (int (input ()))
import math
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
lmczao = 1
for i in ll:
  lmczao = lcm (lmczao, i)
sum = 0
for i in ll:
  sum = (sum + lmczao / i) % sum
print (sum)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
from functools import reduce

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



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

l = [0] * (10 ** 6 + 1)

for i in range(n):
    soi = factorize(a[i])
    for j in range(len(soi)):
        l[soi[j][0]] = max(l[soi[j][0]], soi[j][1])

saiko = 1

for i in range(2, 10**6):
    saiko = (saiko * i ** l[i]) % mod

ans = 0

for i in range(n):
    ans += saiko * pow(a[i],mod - 2, mod)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
def modlog(x, y):
    r = x % y
    return r
  
def gcd(x, y):
    r = modlog(x, y)
    while r != 0:
        x = y
        y = r
        r = modlog(x, y)
    return y
  
def lcm(x, y):
    return int((x * y) / gcd(x, y))

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

p = 1

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

ans = 0
for i in a:
    ans = (ans + int(p/i))%1000000007

print(ans)

Submission status: Runtime Error

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

import fractions

f = 1
for aa in a:
    ff=fractions.gcd(f,aa)
    f = int(f*aa/ff)

print(0)
#ans = 0
#for aa in a:
#   ans += f/aa
#
#print(int(ans%(1000000000+7)))

Submission status: Runtime Error

Solution code:
from functools import reduce
def gcd(*numbers):
  from math import gcd
  return reduce(gcd, numbers)
def lcm(*numbers):
  def lcm(a,b):
    return (a*b)//gcd(a,b)
  return reduce(lcm, numbers, 1)
x = input()
y = list(map(int, input().strip().split(' ')))
l = lcm(*y)
s = sum([l/i for i in y])%1000000007
print(int(s))

Submission status: Runtime Error

Solution code:
#coding: utf-8

import fractions

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

lcm = a[0]
for aa in a[1:]:
    lcm = lcm * aa // fractions.gcd(lcm, aa)
lcm = int(lcm)
B = (int(lcm/aa) for aa in a)
s = 0
for bb in B:
    s += bb
    s %= 1000000007

print(s)

Submission status: Runtime Error

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

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

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


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


temp = lcm_list(A)
l = np.array([temp for _ in range(N)])
l = l/A
ans = 0
for i in l:
    ans += i%(10**9+7)
print(int(ans))

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(*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()))
print(a)

mmod = int(1e9+7)
alcm = lcm(*a)

sum = 0
for i in range(0,n):
    sum = sum + alcm/a[i]

print(int(sum % mmod))

Submission status: Runtime Error

Solution code:
import fractions

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

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

ans = 0
for i in range(n):
    ans += int(lcm/A[i])
    ans = ans % mod

print(ans)

Submission status: Runtime Error

Solution code:
# Hello World program in Python
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
	
N = int(raw_input())
A = map(int, raw_input().split())
l = 1
for x in A:
    l = lcm(l, x)
ans, mod = 0, 1000000007
for x in A:
    ans = (ans + l/x) % MOD
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
M = 10**9+7
n = int(input())
a = tuple(map(int, input().split()))

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

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


a_lcm = lcm(*a)
ans = 0

for i in range(n):
    ans += (a_lcm // a[i])
    ans %= M

print(ans)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
t = list(map(int, input().split()))
l=[0 for i in range(n)]
ans = t[0]
for i in range(1, n):
    ans = ans * t[i] // math.gcd(ans, t[i])
for j in range(n):
    l[j]=ans//t[j]
print(sum(l)%(10**9+7))

Submission status: Runtime Error

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

mul = 1
LCM = arr[0]
MOD = 1000000007

for num in arr:
	LCM = (num*LCM)//(math.gcd(num, LCM))

# print(LCM)
s = 0


for num in arr:
	s = (s + ( LCM//num ))%MOD

print(s)