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:
N = int(input())
A = [int(i) for i in input().split()]
pn = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443,
      449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
lcm = dict()
mod = 10**9+7
for a in A:
    i = 0
    while a != 1:
        c = 0
        n = pn[i]
        while a % n == 0:
            a //= n
            c += 1
        if not n in lcm:
            lcm[n] = 0
        lcm[n] = max(lcm[n], c)
        i += 1
l = 1
for n in lcm.keys():
    l *= pow(n, lcm[n], mod)
    l %= mod
ans = 0
for a in A:
    p = pow(a, mod-2, mod)
    ans += (l*p)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
from functools import reduce
from operator import mul

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

mod = 10**9+7

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        for j in range(i*2, n+1):
            if j%i == 0:
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(max(A))

def primeFactorization(n):
    temp = n
    ans = [0 for _ in range(len(primes))]
    for i in range(len(primes)):
        while temp%primes[i] == 0:
            temp /= primes[i]
            ans[i] += 1
    return ans

AFactorized = list(map(primeFactorization, A))

lcm = [0 for _ in range(len(primes))]
for i in AFactorized:
    lcm = np.maximum(lcm, i)

B = [lcm-a for a in AFactorized]

ans = 0
for b in B:
    ans += reduce(mul, primes**b%mod)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
from functools import reduce
from operator import mul

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

mod = 10**9+7

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        for j in range(i*2, n+1):
            if j%i == 0:
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(A)
# primes = sieve(int(max(A)**0.5)+1)

def primeFactorization(n):
    temp = n
    ans = [0 for _ in range(len(primes))]
    for i in range(len(primes)):
        while temp%primes[i] == 0:
            temp /= primes[i]
            ans[i] += 1
    return ans

AFactorized = list(map(primeFactorization, A))

lcm = [0 for _ in range(len(primes))]
for i in AFactorized:
    lcm = np.maximum(lcm, i)

B = [lcm-a for a in AFactorized]

ans = 0
for b in B:
    ans += reduce(mul, primes**b%mod)
    ans %= mod

print(ans)

Submission status: Runtime Error

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

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

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

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

B = []
for i in range(N):
    B.append(int(l / A[i]))

res = 0
for i in range(N):
    res = res + B[i]
    res = res % 1000000007

print(res)

Submission status: Runtime Error

Solution code:
from math import*
n=int(input())
mod=1000000007
s=[int(j) for j in input().split()]
ans=1
for i in s:
    ans*=i//gcd(ans,i)
print(sum(ans//i for i in s)%mod)

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7
n = int(input())
lst = list(map(int, input().split()))
koubai = lst[0]
def gcd(a, b):
    if a > b:
        a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a
for i in range(1, n):
    koubai = koubai*lst[i]//gcd(koubai, lst[i])
 
total = 0
for i in lst:
    total += koubai//l

print(total%mod)

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7
n = int(input())
lst = list(map(int, input().split()))
koubai = lst[0]
def gcd(a, b):
    if a > b:
        a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a
for i in range(1, n):
    koubai = koubai*lst[i]//gcd(koubai, lst[i])
 
total = 0
for l in lst:
    b += koubai//l

print(total%mod)

Submission status: Runtime Error

Solution code:
import sys
from math import gcd
from functools import reduce

MOD = 1000000007
lcm = lambda x, y: (x*y)//gcd(x,y)
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
l = reduce(lcm, a)
ans = 0
for x in a:
    ans += l//x
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
mod=1000000007
sum=0
s=[int(n) for n in input().split()]
ans=1
for i in s:
    ans*=i//math.gcd(ans,i)
for i in s:
    sum=(sum+ans//i)%mod
print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
A = np.array([int(n) for n in input().split()], dtype=np.uint64)

lcm = np.lcm.reduce(A)

print(int((lcm // A).sum() % (pow(10, 9) + 7)))

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
lcm=[0]*(max(a)+1)
for i in range(n):
  k=a[i]
  for j in range(1,int(a[i]**0.5)+1):
    cnt=0
    while k%(j+1)==0:
      k//=j+1
      cnt+=1
    lcm[j+1]=max(cnt,lcm[j+1])
  lcm[k]=max(1,lcm[k])
lcmn=1
for i in range(len(lcm)):
  if lcm[i]>0:
    lcmn*=i**lcm[i]
ans=0
for i in range(n):
  ans+=(lcmn//a[i])%mod
print(ans%mod)

Submission status: Runtime Error

Solution code:
from collections import Counter, defaultdict
from math import sqrt

MOD = 10**9+7
p_list = defaultdict(int)

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    for i in a:
        l = Counter(prime_decomposition(i))
        for k, v in l.items():
            p_list[k] = max(p_list[k], v)
    
    lcm = 1
    for k, v in p_list.items():
        lcm *= k**v

    ans = 0
    for i in a:
        ans += lcm // i

    print(int(ans) % MOD)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from collections import defaultdict

class LCM_mod:
    """
    最小公倍数の計算を行う
    オーバーフローが発生しないように素因数分解し,
    因数の積を逐次余りに置き換えて最小公倍数を導出する.
    """
    def __init__(self, max_num, p=10**9+7):
        self.max_num = max_num + 1
        self.p = p
        self.prime = [0 for _ in range(self.max_num)]
        self.max_map = defaultdict(int)
        self.sieve()

    def rep_sqr(self, base, k):
        # 繰り返し二乗法
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k / 2) ** 2) % self.p
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.p

    def sieve(self):
        """
        エラトステネスの篩　O(n)
        nまでに含まれる素数を導出
        """
        self.prime[0], self.prime[1] = 1, 1
        for i in range(2, self.max_num):
            if self.prime[i] == 0:
                for j in range(i * 2, self.max_num, i):
                    if self.prime[j] == 0:
                        self.prime[j] = i
                self.prime[i] = i

    def lcm_list_mod(self, arr):
        """
        listのそれぞれの要素について、素因数分解する
        それぞれの因数について最大であれば更新する
        """
        for i in range(len(arr)):
            num = arr[i]
            d = defaultdict(int)

            while num > 1:
                fact = self.prime[num]
                d[fact] += 1
                num //= fact

            for i in d.keys():
                self.max_map[i] = max(self.max_map[i], d[i])

        ans = 1
        for i in self.max_map.keys():
            ans = (ans * self.rep_sqr(i, self.max_map[i])) % self.p
        return ans


class FLT:
    def __init__(self, mod=10**9+7):
        self.mod = mod

    def rep_sqr(self, base, k):
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k // 2) ** 2) % self.mod
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.mod

    def inv(self, a):
        """ 逆元を取る """
        return self.rep_sqr(a, self.mod-2)

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

lcm_mod = LCM_mod(max(a), MOD)
lcm_all = lcm_mod.lcm_list_mod(a)
flt = FLT(MOD)

b = list(map(lambda x: lcm_all * flt.inv(x, MOD), a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

M = 10 ** 9 + 7

def calc_primes(n):
	max = math.ceil(math.sqrt(n))
	table = [True] * (max + 1)
	i = 2
	while i <= max:
		if table[i]:
			j = i * 2
			while j <= max:
				table[j] = False
				j *= 2
		
		i += 1
	primes = []
	for i in range(2, max + 1):
		if table[i]:
			primes.append(i)
	return primes

factor_cache = {}

def calc_factors(n, i = 0):
	if n in factor_cache:
		return factor_cache[n]
	max = math.ceil(math.sqrt(n))
	p = primes[i]
	while True:
		if n % p == 0:
			factors = calc_factors(n // p, i).copy()
			if p in factors:
				factors[p] += 1
			else:
				factors[p] = 1
			factor_cache[n] = factors
			return factors
		else:
			i += 1
			if i >= prime_count:
				break
			p = primes[i]
	if n != 1:
		factors = {n: 1}
		factor_cache[n] = factors
		return factors
	else:
		return {}

N = int(input())

primes = calc_primes(N)
prime_count = len(primes)

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

total_factors = {}
factors_list = []

for A in A_list:
	factors = calc_factors(A)
#	print(factors)
	factors_list.append(factors)
	for factor, count in factors.items():
		if factor not in total_factors:
			total_factors[factor] = count
		elif total_factors[factor] < count:
			total_factors[factor] = count

total = 0
for A, factors in zip(A_list, factors_list):
	B = 1
	for factor, count in total_factors.items():
		if factor in factors:
			count -= factors[factor]
#		for _ in range(count):
#			B = (B * factor) % M
		B = (B * pow(factor, count, M)) % M
	total = (total + B) % M

print(total)

Submission status: Runtime Error

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

    def prime_factorization_dict(n):
        from collections import defaultdict
        """nを素因数分解したときの素数とその指数の辞書"""
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return {i: 0 for i in range(n + 1) if is_prime[i]}

    lcm_prime = prime_table(1000)
    for a in A:
        for base, exp in prime_factorization_dict(a).items():
            lcm_prime[base] = max(lcm_prime[base], exp)
    lcm = 1
    for base, exp in lcm_prime.items():
        lcm *= pow(base, exp, MOD)
        lcm %= MOD
    coefficient = sum(pow(a, MOD - 2, MOD) for a in A)
    return (lcm * coefficient) % MOD

print(e_flatten_prime_factorization())

Submission status: Runtime Error

Solution code:
def e_flatten_prime_factorization(MOD=10**9 + 7):
    from collections import defaultdict
    N = int(input())
    A = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    lcm_prime = defaultdict(int)
    for a in A:
        for base, exp in prime_factorization_dict(a).items():
            lcm_prime[base] = max(lcm_prime[base], exp)
    lcm = 1
    for base, exp in lcm_prime.items():
        lcm *= pow(base, exp, MOD)
        lcm %= MOD
    coefficient = sum(pow(a, MOD - 2, MOD) for a in A)
    return (lcm * coefficient) % MOD

print(e_flatten())

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
N = int(input())
l = list(map(int, input().split(" ")))
 
p = gcd(l)

c = 0
for i in l:
  c += i // p
print(c // (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
N = int(input())
l = list(map(int, input().split(" ")))
 
p = gcd(l)
 
n = reduce(lambda a, b: a * b, l) / (p ** N) / (10 ** 9 + 7)
print(n)

Submission status: Runtime Error

Solution code:
def e_flatten(MOD=10**9 + 7):
    from math import gcd
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    lcm = reduce(lambda x, y: x * y // gcd(x, y), A) % MOD
    coefficient = sum(pow(a, MOD - 2, MOD) for a in A)
    return (lcm * coefficient) % MOD

print(e_flatten())

Submission status: Runtime Error

Solution code:
import math
from fractions import reduce

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

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

p = gcd(l)

n = reduce(lambda a, b: a * b, l) / (p ** N) / (10 ** 9 + 7)
print(n)

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# from functools import reduce
# from math import gcd as gcd_base  # from fractions import gcd
# gcd = lambda *numbers: reduce(gcd_base, numbers)  # 3 数以上の最大公約数

# lcm_base = lambda x, y: (x * y) // gcd_base(x, y)
# lcm = lambda *numbers: reduce(lcm_base, numbers, 1)  # 3 数以上の最小公倍数
# 最小公倍数
# def gcd(a, b):
#     if a < b:
#         a, b = b, a
#     while a % b != 0:
#         a, b = b, a % b
#     return b


## 最大公約数 
def lcm(a, b):
    y = a*b // gcd(a, b)
    return y

def many_lcm(l):
    for i in range(len(l)-1):
        if i == 0:
            ans = lcm(l[0], l[1])
        else:
            ans = lcm(l[i+1], ans)
    return ans
N = INT()
A = LIST()

lm = many_lcm(A)
# print(l)
B = []
for a in A:
    B.append(lm // a)
print(sum(B) % mod)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
 
N,*A = map(int,read().split())
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
 
answer = sum((lcm//x) % MOD for x in A)
answer %= MOD

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# from functools import reduce
# from math import gcd as gcd_base  # from fractions import gcd
# gcd = lambda *numbers: reduce(gcd_base, numbers)  # 3 数以上の最大公約数

# lcm_base = lambda x, y: (x * y) // gcd_base(x, y)
# lcm = lambda *numbers: reduce(lcm_base, numbers, 1)  # 3 数以上の最小公倍数
# 最小公倍数
# def gcd(a, b):
#     if a < b:
#         a, b = b, a
#     while a % b != 0:
#         a, b = b, a % b
#     return b


## 最大公約数 
def lcm(a, b):
    y = a*b / gcd(a, b)
    return int(y)

def many_lcm(l):
    for i in range(len(l)-1):
        if i == 0:
            ans = lcm(l[0], l[1])
        else:
            ans = lcm(l[i+1], ans)
    return ans
N = INT()
A = LIST()

lm = many_lcm(A)
# print(l)
B = []
for a in A:
    B.append(lm // a)
print(sum(B) % mod)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = 0
b = []
for i in a:m = max(0, i)
for i in range(m+1):b.append(0)


for i in a:
    c = 2
    p = i
    while(p>1):
        t = 0
        while(p%c == 0):
            t+=1
            p = p/c
        b[c] = max(b[c], t)
        c+=1
ans = 1
for i in range(len(b)):
    if(b[i]!=0):ans *= (i**(b[i]))

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

MOD = int(1e9)+7

def extgcd(a, b):
    if b == 0:
        return [1, 0, a]
    x, y, g = extgcd(b, a%b)
    return [y, x - a//b * y, g]


def mod_inverse(a, m):
    x, y, _ = extgcd(a, m)
    return (m+x%m) % m


n, k = map(int, input().split())

maxf = 2*n + 10
f = [1 for _ in range(maxf)]
invf = [1 for _ in range(maxf)]

for i in range(1, maxf):
    f[i] = (i * f[i - 1]) % MOD
 
invf[maxf-1] = pow(f[maxf - 1], MOD-2, MOD)
for i in range(maxf-1, 0, -1):
    invf[i-1] = (i*invf[i]) % MOD
 
def comb(a, b):
    if b > a:
        return 0
    return (((f[a]*invf[b]) % MOD) * invf[a-b]) % MOD

a = [ int(x) for x in input().split() ]
a.sort(reverse=True)

ans = 0

for i, v in enumerate(a):
    ans += v*comb(n-i-1, k-1)
    ans %= MOD
    ans -= v*comb(i, k-1)
    ans %= MOD
    
print(ans)

Submission status: Runtime Error

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

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

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

ans = 0
for i in range(n):
    ans += val // a[i]
print(ans % (10**9+7))

Submission status: Runtime Error

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

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

a1 = a[0]
for i,name in enumerate(a[1:]):
    a1 = lcm(a1, name)

result =0
for i in a:
    result += (a1//i)%mod
    result %= mod

print(result)

Submission status: Runtime Error

Solution code:
import math 

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

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

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

ret = 0
for a in A:
    ret += (_lcm // a)
    ret %= MODE

print(ret)

Submission status: Runtime Error

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

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

a1 = a[0]
for i,name in enumerate(a[1:]):
    a1 = lcm(a1, name)

result =0
for i in a:
    result += (a1//i)%mod

print(result)

Submission status: Runtime Error

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

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

a1 = a[0]
soi = [a[0]]
for i,name in enumerate(a):
    c1 = gcd(a1, name)

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

a1 = a[0]
mod_sum = 0
mod1 = 1
for i,name in enumerate(a[1:]):
    ab1 = lcm(a1, name)
    a1 = copy.deepcopy(ab1)

result =0
for i in a:
    result += (ab1//i)%mod

print(result)

Submission status: Runtime Error

Solution code:
from math import gcd
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
if n == 1:
	print(1)
else:
	lcm = a[0] * a[1] // gcd(a[0], a[1])
	for x in a[2:]:
		lcm = lcm * x // gcd(lcm, x)
	print(sum([(lcm//x)%MOD for x in a])%MOD)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

n = ii()
a = li()

lcm = a[0]
for i in a:
	lcm = (lcm * i) // gcd(lcm, i)

sum = 0
for i in a:
	sum += (lcm // i) % (1000000007)
	sum %= (1000000007)

print(sum)

Submission status: Runtime Error

Solution code:
from math import gcd
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

mod = 10**9 + 7

n = ii()
a = li()

lcm = a[0]
for i in a:
	lcm = (lcm * i) // gcd(lcm, i)

sum = 0
for i in a:
	sum += (lcm // i) % mod
	sum %= mod

print(sum)

Submission status: Runtime Error

Solution code:
import math

MOD = 1000000007

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

N = int(input())
A = [int(x) for x in input().split()]
lc = 1
for i in A:
    lc = lcm(lc, i)
ans = 0
for i in A:
    ans = (ans + lc // i) % MOD
print(ans)

Submission status: Runtime Error

Solution code:
#a,bにゼロははいってこない　１回以上の再帰
def gcm(a,b): 
  if b==0:
    return a
  else:
    return gcm(a,b%a) if b>=a else gcm(b,a%b)
def lcm(a,b):
  return a*b//gcm(a,b)

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

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

ans=0
for x in a:
    ans+=lcm_2//x
    ans%=10**9+7

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from fractions import gcd
def lcm(x,y):
  return x * y // gcd(x,y)
def list_gcd(list):
    c=list[0]
    for i in list:
        c=gcd(c,i)
    return c
def list_lcm(list):
  c=1
  for i in list:
    c=lcm(c,i)//mod
  return c
a = [i//list_gcd(a)//mod for i in a]
a = [list_lcm(a) // i //mod for i in a]
print(sum(a)//mod)

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions
def LCM(a,b):
    a=int(a)
    b=int(b)
    return a*b/fractions.gcd(a,b)
n=int(input())
lst= list(map(int,input().split()))
res=reduce(LCM, lst, 1)
ans=0
for x in lst:
    ans+=res//x
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions
def LCM(a,b):
    a=int(a)
    b=int(b)
    return a*b/fractions.gcd(a,b)
n=eval(input())
lst= list(map(int,input().split()))
res=reduce(LCM, lst, 1)
ans=0
for x in lst:
    ans+=res/x
ans=int(ans)
ans=ans%1000000007
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
def LCM(a,b):
    a=int(a)
    b=int(b)
    return a*b/fractions.gcd(a,b)
n=eval(input())
lst= list(map(int,input().split()))
res=1
for x in lst:
    res=LCM(res,x)
ans=0
for x in lst:
    ans+=res/x
ans=int(ans)
ans=ans%1000000007
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]
n=int(input())
a=list(map(int,input().split()))
lcm=a[0]
mod=10**9+7
for i in range(1,n):
  lcm=(lcm//gcd(lcm,a[i]))*(a[i]//gcd(lcm,a[i]))*gcd(lcm,a[i])
ans=0
for i in range(n):
  ans+=lcm*inv[a[i]]%mod
print(ans%mod)

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

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


n = int(input())

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

lcm = lcm_list(inp_list)

ans = 0

for i in inp_list:
    ans += lcm // i


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

Submission status: Runtime Error

Solution code:
def GCD(a,b):
    if a%b==0:
        return b;
    else:
        return GCD(b,a%b)
def LCM(a,b):
    a=int(a)
    b=int(b)
    return a*b/GCD(a,b)
n=eval(input())
lst= list(map(int,input().split()))
res=1
for x in lst:
    res=LCM(res,x)
ans=0
for x in lst:
    ans+=res/x
ans=int(ans)
ans=ans%1000000007
print(ans)

Submission status: Runtime Error

Solution code:
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1e9 + 7;
template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);

    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
template <typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
int main() {
    int n; cin >> n;
    vector<long long> arr(n);
    rep(i, n) cin >> arr[i];

    long long lcms = 1;
    auto x = arr[0];
    bool is_same = true;
    for (auto a: arr) {
        lcms = lcm(lcms, a);
        if (x != a) is_same = false;
    }

    if (is_same) {
        cout << n << endl;
    } else {
        modint<MOD> ans;
        for (auto a: arr) {
            ans = (ans + lcms / a);
        }
        cout << ans.a << endl;
    }
}

Submission status: Runtime Error

Solution code:
import math
def LCM(a,b):
    a=int(a)
    b=int(b)
    return a*b/math.gcd(a,b)
n=eval(input())
lst= list(map(int,input().split()))
res=1
for x in lst:
    res=LCM(res,x)
ans=0
for x in lst:
    ans+=res/x
ans=int(ans)
ans=ans%1000000007
print(ans)

Submission status: Runtime Error

Solution code:
import math
def LCM(a,b):
    a=int(a)
    b=int(b)
    return a*b/math.gcd(a,b)
n=eval(input())
lst= list(map(int,input().split()))
res=1
for x in lst:
    res=LCM(res,x)
ans=0
for x in lst:
    ans+=res//x
ans=int(ans)
ans=ans%1000000007
print(int(ans))

Submission status: Runtime Error

Solution code:
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
    
MOD = int(1000000000+7)

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

first = [1]
second = [1]

k = 1

for i in range(1, n):
    g = gcd(a[0], a[i])
    first.append(int(a[0]/g))
    second.append(int(a[i]/g))


for i in range(1, n):
    k = k * int(second[i]/ gcd(k, second[i]))
    
sum = 0
for i in range(0, n):
    sum += int(first[i] * int(k/second[i]))
    sum %= MOD
    
print(sum)

Submission status: Runtime Error

Solution code:
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
    
MOD = int(1000000000+7)

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

first = [1]
second = [1]

k = 1

for i in range(1, n):
    g = gcd(a[0], a[i])
    first.append(int(a[0]/g))
    second.append(int(a[i]/g))


for i in range(1, n):
    k = k * (second[i]/ gcd(k, second[i]))
    
sum = 0
for i in range(0, n):
    sum += (first[i] * int(k/second[i]))
    sum %= MOD
    
print(sum)