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

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
for a in A:
    res += (lcm // a)

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

Submission status: Runtime Error

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

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

N = int(input())
A =list(map(int,input().split()))
 
if N== 1:
    print(1)
    exit(0)
else:
    tmp = lcm(A[0],A[1])
    for i in range(1,N):
        tmp = lcm(tmp,A[i])
#print(tmp)
ans = 0
for i in range(0,N):
    ans += (int)(tmp/A[i])
    ans %= mod
print(ans)

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
for i in range(N):
  S=S+b[i]/ans
M=10**9+7
print(int(S%M))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy

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

lcm = numpy.lcm.reduce(a)

s = 0
for i in range(n):
    s += lcm // a[i]

ans = s % 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:
#!/usr/bin/env python3
import sys
import numpy as np

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    lcm=np.lcm.reduce(A)
    ans=0
    for i in range(N):
        ans+=lcm//A[i]
    print(ans%MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

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:
def gcd(a, b):
    if b < a:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b


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) // 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:
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=1
for i in range(0,n):
    l=lcm(l,a[i])
ans=0
for i in range(0,n):
    ans=ans+l/a[i]
print (int(ans%(10**9+7)))

Submission status: Runtime Error

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

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

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

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()))
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 numpy import*
M=10**9+7
_,a=open(0)
a=int64(a.split())
print(sum(lcm.reduce(a)//a)%M)

Submission status: Runtime Error

Solution code:
import math
def lcm(x, y):
    return int((x * y) / math.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:
import math
from functools import reduce

res = 1e9 + 7

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())
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:
from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
mod=10**9+7
N = int(input())
A = list(map(int,input().split()))

def pow_mod(x,n):
    if n==0:
        return 1
    
    K = 1
    while n>1:
        if n%2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

Gcd = lcm(A[0],A[1])
ans = Gcd//A[0]+Gcd//A[1]
temp = Gcd//A[1]
#print(temp)

for i in range(1,N-1):
    Gcd = lcm(A[i],A[i+1])
    temp2 = Gcd//A[i]
    Gcd2 = lcm(temp,temp2)
    #print(Gcd)
    #print(temp)
    #print(temp2)
    #print(Gcd2)
    a = Gcd2//temp
    b = Gcd2//temp2

    temp = Gcd//A[i+1]*b

    a %= mod
    b %= mod
    ans *= a
    ans %= mod
    ans += Gcd//A[i+1]*b
    ans %= mod


print(ans)

Submission status: Runtime Error

Solution code:
import math

MOD = 1000000000 + 7

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

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

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

ans = 0
for i in A:
    ans += (l // i) % MOD
print(int(ans % MOD))

Submission status: Runtime Error

Solution code:
import fractions

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

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:
import math
N = int(input())
As = list(map(int, input().split()))
lcm = 1

for a in As:
    gcd_now = math.gcd(lcm,a)
    lcm = lcm*a//gcd_now

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

Submission status: Runtime Error

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

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

for i in range(1, N):
    answer += (first * x // A[i]) % MOD

print(answer%MOD)

Submission status: Runtime Error

Solution code:
# Hello World program in Python
import math
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:

from math import *

mod=10**9+7

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


lcm=a[0]

for i in range(1,n):
	if(gcd(lcm,a[i])==0):
		exit()
	lcm=(lcm*a[i])//gcd(lcm,a[i])



sm=0

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

print(sm)

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():
    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:
N = int(input())
import math
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, N):
    lcm = int(lcm * a[i] / math.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:
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]) // 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 fractions
import numpy as np
MOD = 10**9+7


N = int(input())
A = np.array(list(map(int,input().split())),dtype = np.int64)
lcm = np.lcm.reduce(A)

A = (lcm // A) % MOD

print(sum(A) % MOD)

Submission status: Runtime Error

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

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

f=a[0]*a[1]/gcd(a[0],a[1])
for i in range(2,n):
    d=a[i]
    e=gcd(f,d)
#     print(e)
    f=(f*d/e)
# print(f)

l=[int(f/i) for i in a]
print(sum(l)%(10**9+7))

Submission status: Runtime Error

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

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 fractions
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

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

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)

Submission status: Runtime Error

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

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

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

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

MOD = 1000000007

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

ans = 0

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

print(int(ans))

Submission status: Runtime Error

Solution code:
from math import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
mod=10**9+7
N = int(input())
A = list(map(int,input().split()))

def pow_mod(x,n):
    if n==0:
        return 1
    
    K = 1
    while n>1:
        if n%2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

Gcd = lcm(A[0],A[1])
ans = Gcd//A[0]+Gcd//A[1]
temp = Gcd//A[1]
#print(temp)

for i in range(1,N-1):
    Gcd = lcm(A[i],A[i+1])
    temp2 = Gcd//A[i]
    Gcd2 = lcm(temp,temp2)
    #print(Gcd)
    #print(temp)
    #print(temp2)
    #print(Gcd2)
    a = Gcd2//temp
    b = Gcd2//temp2

    temp = Gcd//A[i+1]*b

    a %= mod
    b %= mod
    ans *= a
    ans %= mod
    ans += Gcd//A[i+1]*b
    ans %= mod


print(ans)

Submission status: Runtime Error

Solution code:
Sanjeev AIT, [19.01.20 18:17]
def fun(a , b):
  if a == 0 :
    return b
  return   fun(b%a , a)    

def add(a , b):
  mod = 1000000007
  return (a % mod + b%mod)%mod
n = int(input())
a = list(map(int,input().strip().split()))
ans = 1
sum = 0
for x in a:
  ans = (ans * x)//fun(ans , x)
for x in a :
  sum = add(sum , ans//x) 
print(sum)

Submission status: Runtime Error

Solution code:
import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c_=c*A_//fractions.gcd(c,A_)
    a=(a*c_/c+c_/A_)%w
    c=c_
print(int(a))

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:
	mul*=num
	LCM = (num*LCM)//(math.gcd(num, LCM))

# print(LCM)
s = 0


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

print(s)

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

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
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

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

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)

Submission status: Runtime Error

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

B = (lcm/aa for aa in a)
s = 0
for bb in B:
    s += bb
    s %= 1000000007

print(int(s))

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]

ans = reduce(math.gcd, B)
if ans != 1:
	B_ = [i//ans for i in B]
	print(sum(B_) % mod)
else:
	print(sum(B) % mod)

Submission status: Runtime Error

Solution code:
import sys
from functools import reduce

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

for i in range(1, N):
    answer += (first * x // A[i]) % MOD

print(answer%MOD)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
from decimal import Decimal

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

x = lcm(a)
ans = Decimal("0")
for i in a:
    ans += x//i

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "Yes" : "No")
#define mod(a, b) (b + (a % b)) % b
#define MOD  (ll)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
typedef std::vector<pii> vpii;
using namespace std;

ll gcd (ll a, ll b) {
    while (b) {
        a %= b;
        swap (a, b);
    }
    return a;
}
ll lcm (ll arr[], int n)
{
    ll ans = arr[0];
    for (int i = 1; i < n; i++){
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));
    }
    return ans;
}
 
void solve(){
    int n;
    cin >> n;
    ll a[200500];
    cina(0, n, a);
    ll lc = lcm(a, n);
    
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += lc / a[i];
        if(ans > MOD) ans %= MOD;
    }
    cout << ans;
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(i) for i in input().split(" ")]
mod=10**9+7

def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def LCM(a,b):
    return int(a*b/GCD(a,b))


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

retval=0
for a in A:
    retval+=lcm/a
    retval=retval%mod

print(int(retval%mod))

Submission status: Runtime Error

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


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


c = 0
for i, a in enumerate(A):
    if i == 0:
        c = a
    else:
        c = lcm(c, a)

result = 0
for a in A:
    result += c // a

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

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

Solution code:

from math import *

mod=10**9+7

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


lcm=a[0]

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

while(1):
	f=1

sm=0

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

print(sm)

Submission status: Runtime Error

Solution code:
def main():

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

    s = set()
    for v in A:
        s.add(v)
    A = sorted(list(s), reverse = True) 

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

    b = 1
    for i in range(N):
        if b % A[i] != 0:
            g = gcd(b, A[i])
            b = b * A[i] // g

    ans = 0
    for i in range(N):
        ans += (b // A[i]) % mod
        ans %= mod
    return ans

if __name__ == '__main__':
    print(main())

Submission status: Runtime Error

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

mul = 1
LCM = arr[0]
for num in arr:
	mul*=num
	LCM = (num*LCM)//(math.gcd(num, LCM))

print(LCM)
s = 0
MOD = 1000000007

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

print(s%MOD)

Submission status: Runtime Error

Solution code:
mod=10**9+7
from math import *
n=int(input())
arr=[int(i) for i in input().split()]
ans=arr[0]
for i in range(1,n):
    ans=(((arr[i] * ans)) // (gcd(arr[i], ans)));
    ans%=mod
sum=0
for i in arr:
    sum+=ans//i
    sum%=mod
print(sum)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(i) for i in input().split(" ")]
mod=10**9+7

def GCD(a,b):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def LCM(a,b):
    return (a*b/GCD(a,b))


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

retval=0
for a in A:
    retval+=lcm/a

print(int(retval%mod))

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd
    from collections import Counter

    N = int(input())
    A = tuple(map(int, input().split()))
    setA = tuple(set(A))
    INF = 10**9 + 7

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

    # A を圧縮
    c = Counter(A)
    values, counts = zip(*c.most_common())

    ans = 0
    for ci in range(len(values)):
        ans += (L // values[ci]) * counts[ci]
        ans %= INF
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def gcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return gcd(y,x%y)
S = [A[1]//gcd(A[0],A[1]),A[0]//gcd(A[0],A[1])]
for i in range(2,N):
    a = A[i-1]*S[i-1]
    b = A[i]*a//gcd(A[i],a)
    c = b//a
    S = list(map(lambda x:x*c,S))
    S.append(b//A[i])
print(sum(S)%mod)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
f=a[0]*a[1]/gcd(a[0],a[1])
for i in range(2,n):
    d=a[i]
    e=gcd(f,d)
#     print(e)
    f=(f*d/e)
# print(f)

l=[int(f/i) for i in a]
print(sum(l)%(10**9+7))

Submission status: Runtime Error

Solution code:
import math

def lcm(a,b):
    return (a*b)//math.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])
ans = 0
mod = 1000000007
for i in a:
    ans = (ans+(l//i))%mod
print(ans)

Submission status: Runtime Error

Solution code:
import fractions as math
from functools import reduce

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


N=int(input())
A=list(map(int,input().split()))
MOD=(10**9)+7
S=list(set(A))
LCM=lcm(A[0],A[1])
for i in range(2,N):
    LCM=lcm(LCM,A[i])
    

ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define mod 1000000007

ll power(ll x,ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    x_=(x_*x_)%mod;
    if(y & 1){
        return (x_*x)%mod;
    }
    else{
        return x_%mod;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    cin>>arr[0];
    ll ans=arr[0];
    FOR(i,1,n){
        cin>>arr[i];
        ans = (((arr[i] * ans)) /
                (__gcd(arr[i], ans)));
        ans%=mod;
    }
    ll sum=0;
    REP(i,n){
        sum=(sum+(ans%mod*power(arr[i],mod-2))%mod)%mod;
    }
    cout<<sum<<endl;
}

Submission status: Runtime Error

Solution code:
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:
def gcd(a:int, b:int):
    while b:
        a,b = b,a%b
    return a
def lcm(a:int, b:int):
    return a*b//gcd(a,b)

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

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

Submission status: Runtime Error

Solution code:
import math

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

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

ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

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

B = (lcm/aa for aa in a)
s = 0
for bb in B:
    s += bb
    s %= 1000000007

print(int(s))

Submission status: Runtime Error

Solution code:
import numpy as np
M = 10**9+7
n = int(input())
a = list(map(int, input().split()))

a_lcm = np.lcm.reduce(a)
ans = 0

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

print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import re
import math
#import numpy as np

mod=int(10**9+7)

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

#main
N=int(input())
A=list(map(int,input().split()))
l=A[0]
for a in A:
    l=lcm(l,a)

ans=0
for a in A:
    ans+=l//a
    ans%=mod
print(ans)

Submission status: Runtime Error

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

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

ans = 0
lcm_ = lcm(List)
for i in range(0, len(List)):
  ans += lcm_/List[i]
  ans %= 1000000007
  
print(int(ans))

Submission status: Runtime Error

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

import fractions as math
#リスト l の最大公約数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

g = lcmlist(lst1)
ans = 0
for i in range(n):
    ans += g//lst1[i]%mod

print(ans%mod)

Submission status: Runtime Error

Solution code:
from math import gcd
import functools

from math import sqrt,ceil
from collections import defaultdict

lim = 10**4 + 10

def sieve(N):
    """Dumb sieve of Eratosthemes, O(N*log(log(N)))"""
    b = [True]*(N+1)
    b[0] = False
    b[1] = False

    lim = ceil(sqrt(N))
    i = 2
    while i <= lim:
        if b[i]:
            for n in range(i**2,N+1,i):
                b[n] = False
        i+=1
    
    return [i for i,b in enumerate(b) if b]

P = sieve(lim)

def factor(n):
    """Given prime list, factorize n. Format as dict of factors with counts."""
    if n in P: return {n: 1}

    F = []
    for p in P:
        while n%p == 0:
            n//=p
            F.append(p)
        if n in P:
            F.append(n)
            break
    else:
        if n != 1:
            F.append(n)

    C = {}
    for f in F:
        if f not in C:
            C[f] = 0
        C[f] += 1

    return C

mod = 1000000007

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

D = defaultdict(int)
for a in A:
    for f,cnt in factor(a).items():
        D[f] = max(D[f], cnt)
l = 1
for f,cnt in D.items():
    l = l*pow(f, cnt, mod) % mod

res = sum(l*pow(a, mod-2, mod) for a in A)
print(res % 1000000007)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)
from fractions import gcd
from functools import reduce

def gcd_lcm(lists):
    LCM = lists[0]
    for i in range(1,len(lists)):
        if i == len(lists) - 1:
            GCD = gcd(LCM,lists[i])
        LCM = (LCM * lists[i]) // gcd(LCM,lists[i])
    return GCD,LCM

def main():
    N = int(input())
    A = sorted([int(i) for i in input().split()])
    MOD = 10**9+7

    GCD,LCM = gcd_lcm(A)
    ans = 0
    if GCD != 1 and LCM == A[-1]:
        for i in range(N):
            ans = (ans + A[-1] // A[i]) % MOD
    else:
        for i in range(N):
            ans = (ans + LCM // A[i]) % MOD

    print(ans)

if __name__ == "__main__":
    main()