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 copy import deepcopy
N = int(input())
A = [int(a) for a in input().split()]

mod = 1000000007

def modplus(x, y):
    return (x + y) % mod

def modminus(x, y):
    return (x - y + mod) % mod

def multiply(x, y):
    return (x % mod) * (y % mod) % mod

def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        p = power(x, y // 2)
        return (p * p) % mod
    else:
        p = power(x, y // 2)
        return ((p * p) % mod) * ((x % mod) % mod)

def divide(x, y):
    return multiply(x, power(y, mod - 2))

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

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

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

lcm_list = deepcopy(A)
while len(lcm_list) > 1:
    new_lcm_list = []
    if len(lcm_list) % 2 == 0:
        for i in range(len(lcm_list)//2):
            # new_lcm_list.append(lcm(lcm_list[2*i], lcm_list[2*i+1]) % mod)
            new_lcm_list.append(lcm(lcm_list[2*i], lcm_list[2*i+1]))
    else:
        for i in range(len(lcm_list)//2):
            # new_lcm_list.append(lcm(lcm_list[2*i], lcm_list[2*i+1]) % mod)
            new_lcm_list.append(lcm(lcm_list[2*i], lcm_list[2*i+1]))
        new_lcm_list.append(lcm_list[-1])
    lcm_list = deepcopy(new_lcm_list)

LCM = lcm_list[0]

ans = 0
for i in range(N):
    # ans += LCM // A[i]
    ans = modplus(ans, divide(LCM, A[i]))
print(ans % mod)

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)%(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 as 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=list(map(int,input().split()))
tmp=lcm_list(A)
ans=0
for i in A:
  ans+=tmp/i
  ans%=(10**9+7)
print(int(ans))

Submission status: Runtime Error

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

# 最大公約数
def gcd(a, b):
    while b != 0:
        tmp = b
        b = a % b
        a = tmp
    return a

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

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

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

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#a, b = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
mod = (10 ** 9) + 7

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

p = lcm(A)

sum = 0
for i in range(N) :
  sum += p/A[i]

print (int(sum%mod))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)

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)

def main():
    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)))

main()

Submission status: Runtime Error

Solution code:
from math import gcd
mod = 10**9 + 7

n = int(input())
arr = [int(j) for j in input().split()]

# prod = 1
# l = 1
# for x in arr:
# 	g = gcd(l, x)
# 	prod = l*x
# 	l = prod//g

# su = 0
# for x in arr:
# 	su += (l//x)
# print(su%mod)

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:
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//A_)*c_/c)%w
    #a=(a*c_//c+c_//A_)%w
    c=c_
print(int(a))

Submission status: Runtime Error

Solution code:
import math
import fractions
from functools import reduce

res = 1e9 + 7

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

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

# lcm_num = lcm_list(As)

sum = 0

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

print(int(sum % res))

Submission status: Runtime Error

Solution code:
from fractions import gcd

def lcm(arr):
    if len(arr)==1:
        return arr[0]
    x = arr[0]
    for i in range(1, len(arr)):
        x = (x * arr[i])//gcd(x, arr[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)

Submission status: Runtime Error

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

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


n = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)


MOD = 10**9+7
ans = 0
tmp = 0


n.times do |i|
  if i == 0
    tmp = A[i]
  else
    tmp = lcm(tmp, A[i])
  end
end


n.times do |i|
  ans += tmp/A[i] % MOD
end

p ans % MOD

Submission status: Runtime Error

Solution code:
import math

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

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

b = [x]
res = x
for i in range(1, n):
    y = a[0] * b[0] // a[i]
    res += y

print(int(res % 1000000007))

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)%w
    #a=(a*c_//c+c_//A_)%w
    c=c_
print(int(a))

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), np.int64)
mod = 10**9+7
LCM = np.lcm.reduce(A)
B = [LCM] * N
B = B // A
#print(LCM)
#print(B)
ans = 0
for i in range(N):
	t = B[i]%mod
	ans += t
	ans %= mod

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
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/A_)*c_//c)%w
    #a=(a*c_//c+c_//A_)%w
    c=c_
print(int(a))

Submission status: Runtime Error

Solution code:
import math

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

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

b = [x]
res = x
for i in range(1, n):
    y = a[0] * b[0] / a[i]
    res += y

print(int(res % 1000000007))

Submission status: Runtime Error

Solution code:
import fractions

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

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

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

print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions

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

N=int(input())
A=list(map(int,input().split()))
a_lcm=A[0]

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

result=0
for i in range(N):
    result+=a_lcm//A[i]
    result%=1000000007
print(result%1000000007)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
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 = input()
list_A = np.array(list(map(int,input().split())
 
lcm = lcm_list(list_A)
lcmlist = np.array([lcm] * N)
list_B = lcmlist // list_A
print(sum(list_B))
import math
import numpy as np
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 = input()
list_A = np.array(list(mat(int,input().split())

lcm = lcm_list(list_A)
lcmlist = np.array([lcm] * N)
list_B = lcmlist // list_A
print(sum(list_B))

Submission status: Runtime Error

Solution code:
from fractions import gcd
MOD=(10**9)+7
n=int(input())
a=list(map(int,input().split()))
a_lcm=a[0]
a_invsum=0

for ai in a:
    a_lcm=(a_lcm*ai) // gcd(a_lcm, ai)
    a_invsum+=1/ai
sum_b=round(a_invsum * a_lcm)
print(sum_b%MOD)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
// E

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

using ll = mp::cpp_int;

ll mod=1e9+7;
//最大公約数
ll gcd(ll a,ll b) {
  if (b == 0){
    return a;
  }
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(){
  int N,A[10000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  if (N == 1){
    cout << 1 << endl;
    return 0;
  }
  ll tmp = lcm(A[0],A[1]);
	for (int i(1);i<N;i++){
    tmp = lcm(tmp,A[i]);
  }
  ll ans(0);
  for (int i(0);i<N;i++){
    ans += (tmp/A[i]);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

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):
    A = A * a[i] // fractions.gcd(A, a[i])

ans = 0
MSD = 1000000007
for i in range(N):
  B = A/a[i]
  ans += (B)%MSD
print(int(ans%MSD))

Submission status: Runtime Error

Solution code:
import numpy as np

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



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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#E

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

Ainv=[]
for i in range(N):
    Ainv.append(pow(A[i],mod-2,mod))
SSS=0
for u in Ainv:
    SSS=(SSS+u)%mod
    
data=[0]*(max(A)+1)
for i in range(N):
    h=prime_factorize(A[i])
    cnt=1
    for i in range(1,len(h)):
        if h[i]==h[i-1]:
            cnt+=1
        else:
            data[h[i-1]]=max(data[h[i-1]],cnt)
            cnt=1
    data[h[-1]]=max(data[h[-1]],cnt)
ans=1
for i in range(1,len(data)):
    if data[i]==0:
        continue
    else:
        ans=ans*pow(i,data[i],mod)%mod
print(ans*SSS%mod)

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
#from fraction import gcd

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

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

def getLCM(numList):
    return reduce(lcm2, numList, 1)

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

print(str(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

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

lc = mp.lcm.reduce(a)

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

print(res)

Submission status: Runtime Error

Solution code:
from math import gcd
mod = 10**9 + 7
n = int(input())
arr = [int(j) for j in input().split()]

prod = 1
l = 1
for x in arr:
	g = gcd(l, x)
	prod = l*x
	l = prod//g

su = 0
for x in arr:
	su += (l//x)
print(su%mod)

Submission status: Runtime Error

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

print(int(count)%((10**9)+7))

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

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

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

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

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

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

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

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

lcm = lcm_list(A)


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

print(int(ans))

Submission status: Runtime Error

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc / a[i]) % int(1e9+7)
    ans %= int(1e9+7)
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

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

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
n = int(input())
box = list(map(int, input().split()))
min_max = lcm_list(box)
b = []
for i in range(n):
  b.append(int(min_max/box[i]))
  
print(int(sum(b)%(1000000000+7)))

Submission status: Runtime Error

Solution code:
import fractions


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


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

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

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

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**5)
from fractions import gcd

def lcm(a):
    if len(a)==1:
        return a[0]
    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:
from functools import reduce
#from math import gcd
from fraction import gcd

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

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

def getLCM(numList):
    return reduce(lcm2, numList, 1)

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

print(str(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 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 fractions
N =int(input())
a = list(map(int, input().split()))
A = a[0]
for i in range(1, N):
    A = A * a[i] // fractions.gcd(A, a[i])
print(A)
ans = 0
MSD = 1000000007
for i in range(N):
  B = A/a[i]
  ans += (B)%MSD
print(int(ans%MSD))

Submission status: Runtime Error

Solution code:
from fractions import gcd
mod = 10**9+7
def lcm(x, y):
  return x//gcd(x, y)*y
n = int(input())
A = list(map(int, input().split()))
cnt = 0
m = lcm(A[0], A[1])
cnt += m//A[0] + m//A[1]
cnt %= mod
for i in range(2, n):
  t = lcm(m, A[i])
  cnt = cnt*(t//m) + t//A[i]
  m = t
  cnt %= mod
print(cnt)

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
import sys
import fractions
import math
input = sys.stdin.readline

N = int(input())

#a, b, c = (int(i) for i in input().split())  
a = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 

ans = a[0]
total = 0
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

for j in range(N):
    total += ans/a[j]

print(int(total%(10**9+7)))

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

try:
    kobai/2
except:
    print(-1)
    break

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

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

print(sumN)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from math import gcd

n = int(input())
arr = [int(j) for j in input().split()]

prod = 1
l = 1
for x in arr:
	g = gcd(l, x)
	prod = l*x
	l = prod//g
	# print(l)

su = 0

for x in arr:
	su += (l//x)
print(su%(10**9 + 7))

Submission status: Runtime Error

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

def getGCD(a,b):
    if a<b:
        a,b=b,a
    r = a%b
    while r!=0:
        a=b
        b=r
        r=a%b
    return b

def getGCDs(A):
    r=getGCD(A[0],A[1])
    for i in A:
        if i !=A[0] and i!=A[1]:
            r = getGCD(r,i)
    return r

num = 1
for i in A:
    num *= i

num = num / getGCDs(A)
ans = 0
for i in A:
    ans += num / i
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions

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

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

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

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
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 = input()
list_A = np.array(list(mat(int,input().split())

lcm = lcm_list(list_A)
lcmlist = np.array([lcm] * N)
list_B = lcmlist // list_A
print(sum(list_B))

Submission status: Runtime Error

Solution code:
const MOD: i64 = 1_000_000_007;


fn gcd(a: i64, b: i64) -> i64 {
    let (mut a, mut b) = (a, b);
    while b != 0 {
        let tmp = a - (a / b) * b;
        a = b;
        b = tmp;
    }
    a
}


fn lcm(iterable: &Vec<i64>) -> i64 {
    let mut a = iterable[0];

    for b in iterable.iter() {
        a = a * b / gcd(a, *b)
    }
    a

}


fn main() {
    let n: i64 = read();
    let an: Vec<i64> = read_vec();

    let lcm_an = lcm(&an);

    let mut ans = 0;
    for a in an.iter() {
        ans += lcm_an / a;
        ans %= MOD;
    }

    println!("{}", ans);

}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
#python 3.5.2
import math

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

ans = 0
for i in range(len(arr)):
    ans = ans + (lcm // arr[i])
    ans = ans % 1000000007
print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
import fractions
mod = 7 + 10 ** 9
lcm = int(A[0] * A[1] // fractions.gcd(A[0], A[1])) 
for i in range(2, N):
    lcm = int(lcm * A[i] // fractions.gcd(lcm, A[i]))
ans = 0
for i in A:
    ans += lcm // i
    ans %= mod
print(ans)

Submission status: Runtime Error

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

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

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

sum_num = 0
div_num = 10**9 + 7
for x in L:
    sum_num += a/x
    if(sum_num > div_num):
        sum_num = sum_num % div_num
ans = int(sum_num)

if (ans > div_num):
    ans = ans % div_num
print(ans)

Submission status: Runtime Error

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

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

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

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

print(int(temp))

Submission status: Runtime Error

Solution code:
import fractions

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

for i in range(N-1):
    if i==0:
        a_lcm=(A[i]*A[i+1])//fractions.gcd(A[i],A[i+1])
    else:
        a_lcm=(a_lcm*A[i+1])//fractions.gcd(a_lcm,A[i+1])

result=0
for i in range(N):
    result+=a_lcm//A[i]
    result%=1000000007
print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
     
n = int(input())
a = []
lcm = 1
for i in range(n - 1):
  t = int(input())
  a.append(t)
      
lc = np.lcm.reduce(a)
     
res = 0;
for i in range(n):
  res = res + lc / a[i];
  res = res % 1000000007
     
print(res)

Submission status: Runtime Error

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

x = lcm(a)
ans = sum([x / a[i] for i in range(len(a))]) % (10 ** 9 + 7)
print(int(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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




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 math
n = int(input())
a = [int(i) for i in input().split()]

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

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

Submission status: Runtime Error

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

    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=0
        for i in range(n):
            ans+=(l//A[i])%mod        
    print(ans%mod)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

res = 1e9 + 7

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

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

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

Submission status: Runtime Error

Solution code:
import fractions

MOD = 1e9 + 7

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

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

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

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**5)
from fractions import gcd

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

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:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

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

kobai=1

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

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

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

print(sumN)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
mod = 1000000007
def gcd(x, y): 
    while(y): 
       x, y = y, x % y 
    return x 
    
def lcm(a, b):
    return abs(a*b) // gcd(a, b)
n = int(input())
ar = list(map(int, input().split()))
lc = ar[0]
for i in range(1,n):
    lc = lcm(lc,ar[i])
ans = 0
for i in range(0,n):
    ans = (ans%mod + (lc/ar[i])%mod)%mod
print(int(ans))

Submission status: Runtime Error

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc / a[i]) % int(1e9+7)
    ans %= int(1e9+7)
print(ans)

Submission status: Runtime Error

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

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

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

sum_num = 0
for x in L:
    sum_num += a/x
ans = int(sum_num)
div_num = 10**9 + 7
if (ans > div_num):
    ans = ans % div_num
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

buf=[]
mul=1

n=int(input())
i=0;
for x in input().split():
    
    buf.append(int(x))  
    mul=mul*(buf[i]/gcd(mul,buf[i]))
    i+=1
sum=0
for i in range(n):
    buf[i]=mul/buf[i]
    sum+=buf[i]
    sum%=1000000007
print(int(sum))

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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