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:
coding: utf-8

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:
N = int(input())
import math
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, N):
    lcm = 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:
# coding:utf-8
import numpy as np

N = int(input())
A = [int(n) for n in input().split(' ')]
div_n = 10 ** 9 + 7
min_a = min(A)
lcm = A[0]

for a in A:
    lcm = np.lcm(lcm, a)

if min_a == lcm:
    print((1*N) % div_n)
else:
    stack = 0
    for a in A:
        stack += lcm // a
    print(stack % div_n)

Submission status: Runtime Error

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
ans = 0
n = int(input())
a = list(map(int,input().split()))
kari = a[0]
for i in a:
    kari = lcm(kari,i)
for i in a:
    ans+=kari/i
print(int(ans%1000000007))

Submission status: Runtime Error

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

import 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:
import fractions

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

# 最小公倍数の算出
ans = A[0]
for i in range(1, N):
    ans = ans * A[i] // fractions.gcd(ans, A[i])
koubai = ans

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:
mod = 10**9+7
def fctr(n): 
    res=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            res.append([i,c])
            c=0
    if n!=1:
        res.append([n,1])
    return res
N = int(input())
A = list(map(int, input().split()))
A_inv = [pow(a, mod-2, mod) for a in A]
primes = [0]*(10**4+1)
for a in A:
    res = fctr(a)
    for i, c in res:
        primes[i] = max(primes[i], c)
m = 1
for i in range(1, 10**4+1):
    c = primes[i]
    m*=pow(i, c, mod)
    m%=mod
ans = 0
for a in A_inv:
    ans+=m*a
    ans%=mod
print(ans)

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)));
sum=0
for i in arr:
    sum+=ans//i
    sum%=mod
print(sum)

Submission status: Runtime Error

Solution code:
from math import gcd # Python versions 3.5 and above
#from fractions import gcd # Python versions below 3.5
from functools import reduce # Python version 3.x

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

    l = lcm(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:
N = int(input())
A = list(map(int,input().split()))
import fractions
X = A[0]
for i in range(1, N):
    X = X * A[i] // fractions.gcd(X, A[i])

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

Submission status: Runtime Error

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

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

L = 1
for i in range(N):
    L = lcm(L, A[i])
ans = 0
for i in range(N):
    ans += L / A[i]
    ans %= M
print(int(ans))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

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

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

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

num_lcm = lcm(*A)
ans = []
for a in A:
    ans.append(num_lcm//a)
print(sum(ans)%1000000007)

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

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

temp = lcm_list(A)
l = [temp for _ in range(N)]
l = np.array(l)/A

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

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

sm=0

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

print(sm)

Submission status: Runtime Error

Solution code:
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 
      
n=int(input())
l=list(map(int, input().split()))
  
num1 = l[0] 
num2 = l[1] 
lcm = find_lcm(num1, num2) 
  
for i in range(2, len(l)): 
    lcm = find_lcm(lcm, l[i]) 
sum=0
k=pow(10,9)+7
for i in l:
  sum+=((lcm//i))%k
print(sum%k)

Submission status: Runtime Error

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

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

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

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

ans = 0
for e in a:
  ans += (p / e)

print(int(ans % 1000000007))

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if b == 0:
        return a 
    return gcd(b, a % b)
    
n = int(input())
lis = list(map(int, input().split()))

lcm = 1

for i in lis:
    lcm = (lcm * i) // gcd(i, lcm)

res = 0
MOD = 1e9 + 7 

for i in lis:
    res = (res + lcm // i) % MOD  
    
print(int(res))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[6]:


N = int(input())
A = list(map(int, input().split()))
"""
3
2 3 4
"""


# In[7]:


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


# In[16]:


t = 1
for i in A:
    t = lcm(t, i)
    #print(t)
ans = 0
for i in A:
    ans += t/i
#print(ans)
print(int(ans % (1e9+7)))


# In[ ]:

Submission status: Runtime Error

Solution code:
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 
      
n=int(input())
l=list(map(int, input().split()))
  
num1 = l[0] 
num2 = l[1] 
lcm = find_lcm(num1, num2) 
  
for i in range(2, len(l)): 
    lcm = find_lcm(lcm, l[i]) 
sum=0
k=pow(10,9)+7
for i in l:
  sum+=(lcm//i)
print(sum%k)

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

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

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

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

LCM = lcm_list(A)
ans = 0

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

Submission status: Runtime Error

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

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

def solve(nums):
  modula = 10**9 + 7
  lcm = find_lcm(nums)

  ans = 0
  for n in nums:
    ans += (lcm // n) % modula

  print(ans % modula)


    
def iin(): return int(input())
def iln(): return list(map(int, input().split()))


N = iin()
nums = iln()
solve(nums)

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)

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

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

mod = 1000000007

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

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

LCM = lcm_list(A)
ans = 0

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

Submission status: Runtime Error

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

MOD=10**9+7

g=A[0]
for i in range(1, N):
    g = g*A[i]//fractions.gcd(g, A[i])
ans=0
for i in range(N):
  ans+=int(g/A[i])%MOD
  ans%=MOD
print(ans)

Submission status: Runtime Error

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

n = int(input())
l = list(map(int, input().split()))
lcm = 1 
  
for i in range(0, len(l)): 
    lcm = find_lcm(lcm, l[i])

ans = 0

for i in range(0, len(l)):
  ans += lcm / l[i]

print(int(ans % 1000000007))

Submission status: Runtime Error

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

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_lcm = lcm(a)

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

print(int(ans))

Submission status: Runtime Error

Solution code:
import math

MOD = 10**9 + 7


def get_lcm(xs):
    ans = xs[0]
    for a in xs[1:]:
        ans = ans * a // math.gcd(ans, a)
    return ans


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

lcm = get_lcm(A)
res = 0
for a in A:
    res += lcm // a
    res = res % MOD

print(res)

Submission status: Runtime Error

Solution code:
import numpy as np

from functools import reduce

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

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


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

a.sort(reverse=True)
v1, v2 = None, None
L = None

# if len(a) > 1:
#     v1 = a[0]
#     v2 = a[1]
#     L = lcm(v1, v2)
#     # print(L)
# else:
#     L = reduce(lcm, a)

L = reduce(lcm, a)

# print(L)

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

print(ans % mod)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[6]:


N = int(input())
A = list(map(int, input().split()))
"""
3
2 3 4
"""


# In[7]:


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


# In[16]:


t = 1
for i in A:
    t = lcm(t, i)
    #print(t)
ans = 0
for i in A:
    ans += t/i
#print(ans)
print(int(ans % (1e9+7)))


# In[ ]:

Submission status: Runtime Error

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

import fractions
lcm_m = a[0]
for i in range(1, N):
    lcm_m = lcm_m * a[i] // fractions.gcd(lcm_m, a[i])
#    lcm_m = (lcm_m%(10^9+7))*(a[i]%(10^9+7))//(fractions.gcd(lcm_m,a[i])%(10^9+7))
#    lcm_m = (lcm_m%(10**9+7))*a[i]//(fractions.gcd(lcm_m%(10**9+7),a[i]))
#print(lcm_m)

sol = 0
for i in range(N):
    sol += lcm_m / a[i]
#print(int(sol)%(10**9+7))
sol=sum([lcm_m//x for x in a])
print(sol%(10**9+7))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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)


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


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

    AN_lcm = lcm_list(AN)

    ans = 0
    for A in AN:
        ans += round(AN_lcm * pow(A, -1))
        ans %= MOD

    print(ans)


main()

Submission status: Runtime Error

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

n = int(input())
s = list(map(int, input().split()))
lcm = 1
for i in range(n):
    lcm = (lcm * s[i]) / gcd(lcm, s[i])

ans = 0
for i in range(n):
	ans += lcm / s[i]
print((int)(ans % (1000* 1000* 1000 + 7)))

Submission status: Runtime Error

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


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


lt = 0
r = 0
mod = 1000000007
res = 0

lcm = [0 for i in range(n)]
rcm = [0 for i in range(n)]
lcm[0] = a[0]
for i in range(1, n):
    g = gcd(lcm[i-1], a[i])
    lcm[i] = lcm[i-1] * (a[i] // g)
rcm[n-1] = a[n-1]
for i in range(n - 1):
    I = n - 2 - i
    g = gcd(rcm[I+1], a[I])
    rcm[I] = rcm[I+1] * (a[I] // g)
for i in range(n):
    if i == 0:
        G = rcm[i+1]
    elif i == n - 1:
        G = lcm[i-1]
    else:
        g = gcd(lcm[i-1], rcm[i+1])
        G = lcm[i-1] * (rcm[i+1] // g)
    g = gcd(G, a[i])
    res = (res + G // g) % mod

print(res)

Submission status: Runtime Error

Solution code:
import math

def gcd_array(x):
    value = x[0]
    for i in range(1, len(x)):
        value = math.gcd(value, x[i])
    return value

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

def lcm_array(x):
    value = x[0]
    for i in range(1, len(x)):
        value = lcm(value, x[i])
    return value 

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A

def solve(N, A, MOD=1000000007):
    lcmv = lcm_array(A)
    bsum = 0
    for i in range(N):
        bsum += (lcmv // A[i])
        bsum %= MOD
    return bsum


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions


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

tp = a[0]
for i in range(1, n):
    tp = tp * a[i] // fractions.gcd(tp, a[i])
# print(tp)
print("{0:.0f}".format(sum(tp//np.array(a)) % (math.pow(10, 9)+7)))

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))
g = a[0]

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

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

ans = 0
for i in range (0, n):
    ans += g / a[i]
    
ans = ans % 1000000007

print(int(ans))

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 i in range(N):
    c_=c*A[i]//fractions.gcd(c,A[i])
    a=a*c_/c+c_/A[i]
    c=c_
print(int(a%w))

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


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

kobai=lcm_list(a)

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

print(sumN)

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

mod = 1000000007

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

Submission status: Runtime Error

Solution code:
import math as m
def lcm(a,b):
    return (a*b)//m.gcd(a,b)
input()
a=[int(i) for i in input().split()]
l=a[0]
for i in a:
    l=lcm(i,l)
s=0
for i in a:
    s+=(l//i)
print(s%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)

n = int(input())
A = [int(i) for i in input().split()]
k = [lcm_list(A)] * n
r = 0
for i in range(n):
    r += k[i]//A[i]
    if r > 10**9+7:
        r %= 10**9+7
print(r)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

ans = 0

for i in range(0, len(l)):
  ans += lcm / l[i]

print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))
g = a[0]

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

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

print(g)

ans = 0
for i in range (0, n):
    ans += g / a[i]
    
ans = ans % 1000000007

print(int(ans))

Submission status: Runtime Error

Solution code:
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 
n = int(input())
a = list(map(int, input().split()))
lcm = a[0]
mod = 10**9+7
for i in range(1, len(a)): 
    lcm = find_lcm(lcm, a[i])
ans = 0
for i in a:
    ans+=lcm*pow(i, mod-2, mod)
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

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



ans = 0

for i in range(N):
  ans += int(lcm / list[i])

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

Submission status: Runtime Error

Solution code:
import sys #追加
sys.setrecursionlimit(500*500)

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

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

LCM = lcm(A)

ans = 0
for a in A:
    ans += int(LCM/a)
    ans %= 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(*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()))
MOD=(10**9)+7

LCM=lcm_list(A)
ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
a = [int(i) for i in input().split()]
ans = a[0]
res = 0
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans,a[i])
for i in range(0,n):
    res += ans / a[i]
    res %= 1e9+7
print(int(res))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
#import fractions


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

tp = a[0]
for i in range(1, n):
    tp = tp * a[i] // math.gcd(tp, a[i])
# print(tp)
print("{0:.0f}".format(sum(tp//np.array(a)) % (math.pow(10, 9)+7)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np
#import fractions


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

tp = a[0]
for i in range(1, n):
    tp = tp * a[i] // math.gcd(tp, a[i])
# print(tp)
print("{0:.0f}\n".format(sum(tp//np.array(a)) % (math.pow(10, 9)+7)))

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

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

def lcms(li):
    return reduce(lcm, li, 1)

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

x = lcms(a)

b = [x//a[i] for i in range(n)]
print(int(sum(b)%(1e9+7)))

Submission status: Runtime Error

Solution code:
import math
N = int(input())
A = [int(x) for x in input().split()]

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

n = int(input())

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

l = 1

for num in nums:
    l = lcm(l, num)


ans = 0
for num in nums:
    ans += (l // num)

ans %= (10 ** 9 + 7)

print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(500*500)

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

LCM = lcm(A)

ans = 0
for a in A:
    ans += LCM/a
    ans %= 1000000007

print(ans)

Submission status: Runtime Error

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
if n == 1:
    ans = 1
else:
    l = a[0]
    for i in a[1:]:
        l = lcm(l, i)
    b = []
    for i in a:
        b.append(l//i)
    ans = sum(b) % (10 ** 9 + 7)
print(ans)

Submission status: Runtime Error

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

N = pow(10,9)+7
def gcd(a,b):
    if b == 0:return a
    else :return gcd(b,a%b)

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

hcm = arr[0]
for i in range(1,n):
    hcm = lcm(hcm,arr[i])

res = 0
for num in arr:
    res += (hcm/num)
    res%=N

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

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

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

lcm = lcm_list(list)

ans = 0

for i in range(N):
  ans += lcm // list[i]

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

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
a = [int(i) for i in input().split()]
ans = a[0]
res = 0
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans,a[i])
for i in range(0,n):
    res += ans / a[i]
print(int(res % (1e9+7)))

Submission status: Runtime Error

Solution code:
from math import gcd
def lcm(a,b):
	p = a*b
	g = gcd(a,b);
	return p//g
MOD = int(10**9+7)
n = int(input())
a = list(map(int,input().split()))
lc = a[0];
for i in range(1,n):
	lc = lcm(a[i],lc)
ans = 0
for i in range(n):
	ans += (lc//a[i])
	ans %= MOD
print(ans)

Submission status: Runtime Error

Solution code:
import math as m
def lcm(a,b):
    return (a*b)//m.gcd(a,b)
n=int(input())
a=[int(i) for i in input().split()]
l=a[0]
for i in a:
    l=lcm(i,l)
s=0
for i in a:
    s+=(l/i)
print(int(s%1000000007))

Submission status: Runtime Error

Solution code:
import numpy as np

def lcm_core(a,b):
    g = np.gcd(a,b)
    return (a*b)//g

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

def lcm(arr):
    m = 10**9+7
    mcnt = 0
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
        mcnt += l//m
        l %= m
    return l,mcnt

n = int(input())
arr = list(map(int,input().split()))
l,mcnt = lcm(arr)

# print(l,mcnt)

# print(l)
m = 10**9+7

ans = 0
for i in range(n):
    temp = l + (m%arr[i])*mcnt
    # print(temp)
    ans += (temp//arr[i]) + (m//arr[i])*mcnt
    ans %= m

print(ans)

Submission status: Runtime Error

Solution code:
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

il ll gcd(ll a,ll b){ return b==0 ? a:gcd(b,a%b) ; }

template<typename T>
il bool chk_max(T&x,const T&y){
	if( x<y ){ x=y; return 1; }
	return 0;
}
const int mod = 1e9+7;

il ll qpow(ll a,ll b){
	ll ans= 1;
	for(; b; b>>=1,a=a*a%mod) if ( b&1 ) {
		ans= ans*a%mod;
	} return ans;
}
il ll inv(ll x){ return qpow(x,mod-2); }

#define Primes map<ll,int>
il Primes primes(ll n){
	int ed = sqrt(n);
	Primes ans;
	rep(i,2,ed) if( n%i==0 ){
		int cnt=0;
		while( n%i==0 ) cnt++, n/=i;
		ans[i]=cnt;
	}
	if( n!=1 ) ans[n]=1;
	return ans;
}

enum{N=10003};

ll a[N],b[N];
Primes mx,p[N];

int main(){
	int n=ci();
	rep(i,1,n) a[i] = ci();
	rep(i,1,n){
		p[i] = primes(a[i]);
		for(Primes::iterator it=p[i].begin();it!=p[i].end();it++)
			chk_max(mx[it->first],it->second);
	}
	rep(i,1,n){
		b[i] = 1;
		for(Primes::iterator it=p[i].begin();it!=p[i].end();it++){
			if( mx[it->first]==it->second ){
				b[i] *= qpow(it->first,it->second);
				mx[it->first] = -1;
			}
		}
	}
//	rep(i,1,n) printf("%lld ",b[i]); pt('\n');
	ll pro=1, ans=0;
	rep(i,1,n) pro=pro*b[i]%mod;
	rep(i,1,n) ans=(ans+pro*inv(a[i]))%mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

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


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

kobai=lcm_list(a)

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

print(sumN)

Submission status: Runtime Error

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

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

common=lcm_list(A)
B=[]
for i in range(N):
    B.append(common//A[i])
print(sum(B)%a)

Submission status: Runtime Error

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

import fractions
lcm_m = a[0]
for i in range(1, N):
    lcm_m = lcm_m * a[i] // fractions.gcd(lcm_m, a[i])
#    lcm_m = (lcm_m%(10^9+7))*(a[i]%(10^9+7))//(fractions.gcd(lcm_m,a[i])%(10^9+7))
#    lcm_m = (lcm_m%(10^9+7))*a[i]//(fractions.gcd(lcm_m%(10^9+7),a[i]))
#print(lcm_m)

sol = 0
for i in range(N):
    sol += lcm_m / a[i]
print(int(sol)%(10**9+7))

Submission status: Runtime Error

Solution code:
# import numpy as np
from fractions import math

from functools import reduce

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



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

L = reduce(lcm, a)

# print(L)

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

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)

ans = 0
for aa in a:
    ans += f/aa

print(int(ans%(1000000000+7)))