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:
def GCD(a,b):
    if(b==0):
        return a
    else:
        aa = a%b
        return GCD(b,aa)
    #return b == 0 ? a:GCD(b,a%b)
n = int(input())
mod = 1e9 + 7
a = []
ans = 1

for i in range(n):
    x = int(input())
    a.append(x)
    
    ans = x /GCD(ans,x)*ans
sum = 0
for i in range(n):
    sum = sum+ans/a[i]
    sum = sum%mod
print(sum)

Submission status: Runtime Error

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

from fractions import gcd
lcm = A[0]
for i in range(1, N):
    lcm = (lcm * A[i]) // gcd(lcm, A[i])

B = []
for ai in A:
  B.append(int(lcm/ai))

ans = 0
for bi in B:
  ans = (ans + bi) % mod

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
def gcd(a, b):
    if b ==0:
        return a
    else:
        return gcd(b,a%b)

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

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


k = 0
for j in a:
    k = (k +  mk / j) %MOD
print(int(k %MOD))

Submission status: Runtime Error

Solution code:
import fractions
import sys
from functools import reduce


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


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


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


def solve(inp):
    N = int(inp.readline().strip())
    A = list(map(int, inp.readline().strip().split(' ')))

    lcm = lcm_list(A)

    r = 0
    for a in A:
        r = (r + int(lcm / a)) % 1000000007

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def lcm(a, b):
    return int(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 += l / a[i]
c %= ((10 ** 9) + 7)

print(str(int(c)))

Submission status: Runtime Error

Solution code:
from fractions import gcd

N = int(input())

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

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)
num=0
for a in A:
  num += l/a
print(int(num % (10e9 +7)))

Submission status: Runtime Error

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

import numpy as np
import fractions
from functools import reduce

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

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

if n == 1:
  ans = 0
else: 
  a_lcm = lcm_list(a)
  a_array = np.array(a)
  b = a_lcm / a_array

  ans = int(np.sum(b) % (10**9 + 7))
 
print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
kbs=a[0]
kys=a[0]
ansans=0
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)

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

#https://qiita.com/maebaru/items/317af98e85e9f4db04f9
def prime_numbers(m):
    # 素数を保持するset
    primes = set()

    # 2以上m以下の素数を数え上げる
    n = 2
    while n <= m:
        # 自身より小さい全ての素数で割り切れなければ、素数とみなせる
        if all(n % i != 0 for i in primes):
            primes.add(n)
        n += 1

    return list(primes)
    
#https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorization(n,primes,primenum_count_for_lcm):
    temp = n
    for i in range(len(primes)):
        if temp%primes[i]==0:
            cnt=0
            while temp%primes[i]==0:
                cnt+=1
                temp //= primes[i]
            if primenum_count_for_lcm[i] < cnt:
                primenum_count_for_lcm[i] = cnt
        if temp < primes[i]:
            break

    if temp!=1:
        idx = primenum_count_for_lcm.index(temp)
        if primenum_count_for_lcm[idx] == 0:
            primenum_count_for_lcm[idx] = 1
            
    #if arr==[]:
    #    arr.append([n, 1])
    
    return primenum_count_for_lcm

primes = prime_numbers(int(10**3))
primes.sort()
primenum_count_for_lcm = [0]*len(primes)
for i in range(N):
    primenum_count_for_lcm = factorization(A[i],primes,primenum_count_for_lcm)

sugoilcm = 1
for i in range(len(primes)):
    sugoilcm *= primes[i]**primenum_count_for_lcm[i]

ans = 0
for i in range(N):
    ans += sugoilcm//A[i]
print(int(ans%(10**9+7)))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//fractions.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(int(t))

Submission status: Runtime Error

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

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)

b = 0

for i in A:
    b += lcm_list(A)/i
print(int(b)%(10**9+7))

Submission status: Runtime Error

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

lcm = 1
mod = 10**9+7

def getprime(n):
    if not isinstance(n, int):
        raise TypeError("Input int")
    if n < 2:
        raise ValueError("N >= 2")
    prime = []
    # 約数はsqrt(N)まで調べればOK
    data = [i+1 for i in range(1,n)]
    while True:
        p = data[0]
        if p >= int(n**0.5):
            return prime+data
        prime.append(p)
        # pで割り切れないものだけを残す
        data = [d for d in data if d%p != 0]

from collections import defaultdict
def factorization(n):
    factors = defaultdict(int)
    if n == 2 or n == 3:
        factors[n] = 1
        return factors
    primes = getprime(int(n**0.5))
    for prime in primes:
        while n % prime == 0:
            factors[prime] += 1
            n //= prime
    if n != 1:
        factors[n] += 1
    return factors

d = defaultdict(int)
for a in As:
    factors = factorization(a)
    for f in factors.keys():
        d[f] = max(d[f],factors[f])

for f in d.keys():
    lcm *= f ** d[f]

ans = 0
for a in As:
    ans += lcm//a
    ans %= mod
print(ans%mod)

Submission status: Runtime Error

Solution code:
mod = 1000000007
n = int(input())

num = [0]*n
s = input().split()
for i in range(len(s)):
    num[i] = int(s[i])
    
def HCF(a, b):
    if b == 0:
        return a
    else:
        return HCF(b, a%b)
    
lcm = num[0]

for i in range(n):
    lcm = (lcm * num[i])/(HCF(lcm, num[i]))

sum = 0

for i in range(n):
    sum = int((sum%mod + (lcm//num[i])%mod)%mod)

print(sum)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
from fractions import gcd
import numpy as np
n=int(input())
A=list(map(int,input().split()))
B=np.array(A)
mod=10**9+7

if n==1:
    print(1)
else:
    g=A[0]
    l=A[0]
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
    ans=int(l*(1/B).sum())
    print(int(ans)%mod)

Submission status: Runtime Error

Solution code:
import math
def main():
	n = int(input())
	lst = [int(x) for x in input().split()]
	lc = lst[0]
	for i in range(1,n):
		lc = (lc*lst[i])//(math.gcd(lc,lst[i]))
	ans = 0
	for i in lst:
		ans = ans+(lc/i)
	ans = ans%(1000000007)
	print(int(ans))
main()

Submission status: Runtime Error

Solution code:
import math
def lcm(A):
    b=A[0]
    for i in A[1:]:
        b=b*i//math.gcd(b,i)
    return b

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

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)

n = int(input())
a = [int(i) for i in input().split()]
ans = 0

lcma = lcm(a)
b = lcma / np.array(a)

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

Submission status: Runtime Error

Solution code:
import math
import fractions
"""
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()))

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

count=0
[count+=a/i for i in A]
    #count+=a/i
    #if count>(10**9)+7:
    #    count=count%((10**9)+7)
print(math.floor(count%((10**9)+7)))

Submission status: Runtime Error

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

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)
		
		
a = 1
for i in range(N):
	a = lcm(A[i], a)
ans = 0
	
for i in range(N):
	ans += a // A[i]
	ans %= MOD
	
print(int(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])

bsum = 0
for i in range(n):
    bsum += (ans / a[i]) 
    bsum = bsum % 1000000007
print(int(bsum))

Submission status: Runtime Error

Solution code:
from decimal import *
import fractions

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

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

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

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
import fractions
from functools import reduce

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

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 += l / a[i]
  c %= ((10 ** 9) + 7)

print(str(int(c)))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

#https://qiita.com/maebaru/items/317af98e85e9f4db04f9
def prime_numbers(m):
    # 素数を保持するset
    primes = set()

    # 2以上m以下の素数を数え上げる
    n = 2
    while n <= m:
        # 自身より小さい全ての素数で割り切れなければ、素数とみなせる
        if all(n % i != 0 for i in primes):
            primes.add(n)
        n += 1

    return list(primes)
    
#https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorization(n,primes,primenum_count_for_lcm):
    temp = n
    for i in range(len(primes)):
        if temp%primes[i]==0:
            cnt=0
            while temp%primes[i]==0:
                cnt+=1
                temp //= primes[i]
            if primenum_count_for_lcm[i] < cnt:
                primenum_count_for_lcm[i] = cnt
        if temp < i:
            break

    if temp!=1:
        idx = primenum_count_for_lcm.index(temp)
        if primenum_count_for_lcm[idx] == 0:
            primenum_count_for_lcm[idx] = 1
            
    #if arr==[]:
    #    arr.append([n, 1])
    
    return primenum_count_for_lcm

primes = prime_numbers(int(10**3))
primes.sort()
primenum_count_for_lcm = [0]*len(primes)
for i in range(N):
    primenum_count_for_lcm = factorization(A[i],primes,primenum_count_for_lcm)

sugoilcm = 1
for i in range(len(primes)):
    sugoilcm *= primes[i]**primenum_count_for_lcm[i]

ans = 0
for i in range(N):
    ans += sugoilcm//A[i]
print(int(ans%(10**9+7)))

Submission status: Runtime Error

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

result = 0

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

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

l = lcm(a[0], a[1])

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

for j in a:
  result += l // j

print(result)

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

N = int(input())

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

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

l = lcm(A)
num=0
for a in A:
  num += l/a
print(int(num % (10e9 +7)))

Submission status: Runtime Error

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


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

    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()))
a.sort()
LCM = 1
for i in a[::-1]:
    LCM = lcm(LCM, i)
ans = 0
for i in a:
    tmp = LCM // i
    ans += tmp
    ans %= 10 ** 9 + 7
print(int(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 = [1000000 - x for x in range(N)]
A = list(map(int, input().split()))

LCM = 1
for i in A:
    LCM = i * LCM / gcd(LCM, i)

ans = 0
for i in A:
    ans = (ans + LCM / i) % 1000000007

print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce, gcd

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

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

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

l = lcm(*A)

l = int(l)
MOD = 1000000007

ans = 0
for i in range(N):
    ans = (ans + l // A[i]) % MOD;

print(ans)

Submission status: Runtime Error

Solution code:
def main():
	import sys
	input = sys.stdin.readline
	import fractions
	from functools import reduce
	n = int(input())
	A = []
	A = list(map(int, input().split()))
	mod = 10**9 + 7
	def lcm_base(x, y):
    	return (x * y) // fractions.gcd(x, y)

	def lcm(*numbers):
    	return reduce(lcm_base, numbers, 1)
	Z = lcm(*A)
	ans = sum(Z//a%mod for a in A)%mod
	print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def lcm(a, b):
  return a * b // gcd (a, b)
  
def lcm_all(a_list):
  a = a_list[0]
  for i in range(len(a_list)-1):
    num = lcm(a, a_list[i+1])
    a = num
  return a

mod = 10**9+7
N = int(input())
a_list = list(map(int,input().split()))
lcm = lcm_all(a_list)
b_list = [0]*N
for i in range(len(b_list)):
  b_list[i] = lcm/a_list[i]
print(int(sum(b_list) % mod))

Submission status: Runtime Error

Solution code:
import fractions

#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))
    kobai = kobai * a // fractions.gcd(kobai, a)


sumN=0

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

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

print(sumN)

Submission status: Runtime Error

Solution code:
# cook your dish here
from math import gcd
def lcm(A):
    b=A[0]
    for i in A[1:]:
        b=b*i//gcd(b,i)
    return b

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

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

kazu = list(map(int, input().split(' ')))

koubai = 1
for i in range(N):
  koubai = lcm(koubai, kazu[i])

yakusu = [int(koubai / n) for n in kazu]

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

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):
	print(i, a[i])
	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().strip())
A = [int(s) for s in input().strip().split()]
M = 10 ** 9 + 7

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

factors = [0] * 1001
large_factors = {}
for a in A:
    d = 0
    while a % 2 == 0:
        d += 1
        a //= 2
    factors[2] = max(factors[2], d)
    for i in range(3, int(a ** 0.5) + 1, 2):
        d = 0
        while a % i == 0:
            d += 1
            a //= i
        factors[i] = max(factors[i], d)
        if a == 1:
            break
    if a > 1000:
        large_factors.add(a)
    elif a > 1:
        factors[a] = max(factors[a], 1)

m = 1
for k, v in enumerate(factors):
    if v > 0:
        m = (m * pow(k, v, M)) % M
for k in large_factors:
    m = (m * k) % M

result = 0
for a in A:
    result = (result + m * modinv(a, M)) % M
print(result)

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
gcd_n = a[0]
for i in range(1, n):
    gcd_n = gcd_n * a[i] // fractions.gcd(gcd_n, a[i])
if n == 1:
	gcd_n = 1
ans = 0
for i in range(n):
    ans += gcd_n / a[i]
    ans %= 1000000007
 
print(int(ans))

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions


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()))
l = lcm_list(a)
ans = sum([l // x for x in a]) %
int(1e9+7)
print(ans)
# print(l)
# print(a)

Submission status: Runtime Error

Solution code:
import math

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)

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

ans = float(As[0] % res)
for i in range(1, N):
     ans = ans // gcd(ans, As[i]) * As[i]

# lcm_num = lcm_list(As)

sum = 0.0

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

print(int(sum % res))

Submission status: Runtime Error

Solution code:
n = int(input());
a = input().split()
for i in range(0, n):
    a[i] = int(a[i])
lcm = 1
from math import gcd
for i in a:
    lcm = lcm * i // gcd(lcm, i)
ans = 0;
for i in a:
    ans += lcm // i;
print (ans % 1000000007)

Submission status: Runtime Error

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

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

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

#@lru_cache(maxsize=1000)
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // np.gcd(x, a[i])
    return x


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

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

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//math.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(int(t))

Submission status: Runtime Error

Solution code:
mod = 1000000007
n = int(input())

num = [0]*n
s = input().split()
for i in range(len(s)):
    num[i] = int(s[i])
    
def HCF(a, b):
    if b == 0:
        return a
    else:
        return HCF(b, a%b)
    
lcm = num[0]

for i in range(n):
    lcm = (lcm * num[i])/(HCF(lcm, num[i]))

sum = 0

for i in range(n):
    sum = (sum%mod + (lcm//num[i])%mod)%mod

print(sum)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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


def cal_lcm(a, b):
  return int(a*b/gcd(a,b))


lcm = 1
ans = 0
for i in range(N):
  lcm_ = cal_lcm(lcm, a_list[i])
  ans = ans*int(lcm_/lcm) % MOD
  ans = (ans + int(lcm_/a_list[i])) % MOD
  lcm = lcm_

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(input())
a = list(map(int,input().split()))   #will work for an int array of any length
lcm = a[0]
for i in a[1:]:
  lcm = lcm*i/gcd(lcm, i)

for i in range(len(a)):
  a[i]=int(lcm/a[i])
print(sum(a)% (pow(10,9)+7))

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):
	print(i, a[i])
	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:
import fractions
import sys
from functools import reduce


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


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


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


def solve(inp):
    N = int(inp.readline().strip())
    A = list(map(int, inp.readline().strip().split(' ')))

    lcm = lcm_list(A)
    B = map(lambda x: int(lcm / x), A)

    r = 0
    for b in B:
        r = (r + b) % 1000000007

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from math import gcd

n = int(input())

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


def find_lcm(x, y):

    return x * y // gcd(x, y)


lcm = 0

for i in range(0, len(l)):
    if i == 0:
        lcm = find_lcm(l[i], l[i+1])
    else:
        lcm = find_lcm(lcm, l[i])

result = 0

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

result = result % (1000000007)

print(int(result))

Submission status: Runtime Error

Solution code:
from fractions import gcd
import numpy as np
n=int(input())
A=list(map(int,input().split()))
B=np.array(A)
mod=10**9+7

if n==1:
    print(1)
else:
    g=A[0]
    l=A[0]
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
    B=B/l
    ans=int((1/B).sum())
    print(ans%mod)

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//math.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(int(t))

Submission status: Runtime Error

Solution code:
import math
#import fractions
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()))

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

count=0
for i in A:
    count+=a/i
    #if count>(10**9)+7:
    #    count=count%((10**9)+7)
print(math.floor(count%((10**9)+7)))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

#https://qiita.com/maebaru/items/317af98e85e9f4db04f9
def prime_numbers(m):
    # 素数を保持するset
    primes = set()

    # 2以上m以下の素数を数え上げる
    n = 2
    while n <= m:
        # 自身より小さい全ての素数で割り切れなければ、素数とみなせる
        if all(n % i != 0 for i in primes):
            primes.add(n)
        n += 1

    return list(primes)
    
#https://qiita.com/snow67675476/items/e87ddb9285e27ea555f8
def factorization(n,primes,primenum_count_for_lcm):
    temp = n
    for i in range(len(primes)):
        if temp%primes[i]==0:
            cnt=0
            while temp%primes[i]==0:
                cnt+=1
                temp //= primes[i]
            if primenum_count_for_lcm[i] < cnt:
                primenum_count_for_lcm[i] = cnt
        if temp < i:
            break

    if temp!=1:
        idx = primenum_count_for_lcm.index(temp())
        if primenum_count_for_lcm[idx] == 0:
            primenum_count_for_lcm[idx] = 1
            
    #if arr==[]:
    #    arr.append([n, 1])
    
    return primenum_count_for_lcm

primes = prime_numbers(int(10**3))
primes.sort()
primenum_count_for_lcm = [0]*len(primes)
for i in range(N):
    primenum_count_for_lcm = factorization(A[i],primes,primenum_count_for_lcm)

sugoilcm = 1
for i in range(len(primes)):
    sugoilcm *= primes[i]**primenum_count_for_lcm[i]

ans = 0
for i in range(N):
    ans += sugoilcm//A[i]
print(int(ans%(10**9+7)))

Submission status: Runtime Error

Solution code:
import sys, copy
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
a = copy.deepcopy(A)
koubai = lcm(a)
B = list(map(lambda x:(koubai/x)%(10**9+7), A))

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

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, N):
    gcc = a * A[i] // fractions.gcd(a, A[i])
    a = gcc
    
b = 0
for i in range(N):
    b = b + gcc // A[i]

c = b % (1000000000 + 7)
print(c)

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)


n = int(input())

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

# 最大公倍数
target_num = lcm(*a)

b = []
for i in range(n):
    b.append(target_num//a[i])

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//math.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(int(t))

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

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

l = 1
# for i in range(len(a)):
#     if(l>a[i]):
#         l = lcm(l,a[i])
#     else:
#         l = lcm(a[i],l)

l = np.lcm.reduce(a)

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

Submission status: Runtime Error

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

import numpy as np
import fractions
from functools import reduce

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

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

if n == 1:
  ans = 1
else: 
  a_lcm = lcm_list(a)
  a_array = np.array(a)
  b = a_lcm / a_array

  ans = int(np.sum(b) % (10**9 + 7))
 
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
import math

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

saikou = lcm_list(a)
ans = 0

for i in a:
  b = saikou / i
  ans += b
  
print(int(ans) % 1000000007)

Submission status: Runtime Error

Solution code:
import numpy as np

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

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

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)

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

ans = float(As[0] % res)
for i in range(1, N):
     ans = ans // gcd(ans, As[i]) * As[i]

# lcm_num = lcm_list(As)

sum = 0

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

print(int(sum % res))