TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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).

Submission attempts (in order):
import fractions

num = int(input())
A = [int(s) for s in input().split()]
ans = A[0]
for i in range(1,num):
    ans = ans * A[i]//fractions.gcd(ans,A[i])
B = [ans//A[s] for s in range(num)]
print(B)
print(sum(B)%(10**(9)+7))

import fractions

num = int(input())
A = [int(s) for s in input().split()]
ans = A[0]
for i in range(1,num):
    ans = ans * A[i]//fractions.gcd(ans,A[i])
B = [ans//A[s] for s in range(num)]
print(sum(B)%(10**(9)+7))

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

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

num = int(input())
A = [int(s) for s in input().split()]
ans = A[0]
for i in range(1,num):
    ans = lcm(ans,A[i])
B = [ans//A[s] for s in range(num)]
print(sum(B)%(10**(9)+7))

Verdicts: Wrong Answer

Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
n = int(input())
a = list(map(int, input().split()))

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

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

res = 0
MOD = 1000000007
for i in range(n):
    res = (res + LCM//a[i]) % MOD
print(res)

n = int(input())
a = list(map(int, input().split()))
 
def gcd(n, m):
    if(m): return gcd(m, n%m)
    else: return n
 
def lcm(n, m):
    return n // gcd(n, m) * m
 
LCM = a[0]
for i in range(1, n):
    LCM = lcm(a[i], LCM)
 
res = 0
MOD = 1000000007
for i in range(n):
    res += LCM//a[i]
    
print(res % MOD)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd

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

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

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


from fractions import gcd
from functools import reduce

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

L = reduce(lambda x, y: x * y // gcd(x, y), set(A))

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


from collections import Counter, defaultdict

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

max_A = max(A)
f = list(range(max_A + 1))
for i in range(2, int(max_A ** 0.5) + 1):
    if f[i] == i:
        f[i::i] = [i] * (max_A // i)


def factors(x):
    factor = defaultdict(int)
    while x != 1:
        factor[f[x]] += 1
        x //= f[x]
    return factor


L = defaultdict(int)
for i in range(N):
    Ai = factors(A[i])
    for p, index in Ai.items():
        L[p] = max(L[p], index)
lcm = 1
for p, index in L.items():
    if index == 0:
        continue
    lcm *= pow(p, index, MOD)
    lcm %= MOD

ans = 0
for Ai in A:
    ans += lcm * pow(Ai, MOD - 2, MOD)
    ans %= MOD
print(ans % MOD)


Verdicts: Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
def lcm(a, b):
    while b:
        a %= b
        a, b = b, a
    gcd = a
    return a * b // gcd


n = int(input())
a = list(map(int, input().split(" ")))
alcm = a[0]
for i in a:
    alcm = lcm(alcm, i)

tot = 0
for num in a:
    tot += alcm // num

print(tot % 1000000007)


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


n = int(input())
a = list(map(int, input().split(" ")))
alcm = a[0]
for i in a:
    alcm = lcm(alcm, i)

tot = 0
for num in a:
    tot += alcm // num

print(tot % 1000000007)


from collections import deque, Counter, defaultdict
from functools import lru_cache
from itertools import permutations
from heapq import (
    heappush,
    heappop,
    heapreplace,
    heappushpop,
    heapify,
    merge,
    nlargest,
    nsmallest,
)
from statistics import mean, median, mode


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


n = int(input())
a = list(map(int, input().split(" ")))
alcm = a[0]
for i in a:
    alcm = lcm(alcm, i)

tot = 0
for num in a:
    tot += alcm // num

print(tot % 1000000007)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from collections import defaultdict

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

def primeCount(N):
    R = int(N**(0.5)) + 1  
    primes = defaultdict(int)  
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return primes

PC = [primeCount(a) for a in set(A)]

primes = defaultdict(int)
for pc in PC:
    for p, c in pc.items():
        if c > primes[p]:
            primes[p] = c

print(0)


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

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

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

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

L %= MOD
coef = 0
for a in A:
    coef += pow(a, MOD - 2, MOD)
print((L * coef) % MOD)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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))


N = int(input())
list = 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)

alllcm = 1

for i in range(N):
  alllcm = lcm(alllcm, list[i])

ans = 0

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

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


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd
mod = 10**9 +7
n = int(input())
a = list(map(int, input().split()))
r = a[0]
for i in range(1, n):
    r = r*a[i]//gcd(r, a[i])
result = 0
for i in a:
    result = (result+r//i)%mod
print(result)

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
memo = defaultdict(int)
base = 0
for i in a:
    base = (base+pow(i, mod-2, mod))%mod
    num = i
    c = 0
    while num%2==0:
        c += 1
        num //= 2
    memo[2] = max(memo[2], c)
    for j in range(3, int(i**.5)+1, 2):
        if num%j==0:
            c = 0
            while num%j==0:
                num //= j
                c += 1
            memo[j] = max(memo[j], c)
    if num != 1:
        memo[num] = max(memo[num], 1)
k = 1
for s, t in memo.items():
    k = (k*pow(s, t, mod))%mod

print((k*base)%mod)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
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)

import fractions

def lcm(x, y):
    return (x * y) // fractions.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)

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)

def gcd(a,b):
    while b!=0:
        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_lcm=A[0]
Mod=10**9+7

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

a_lcm%=Mod

result=0
for i in range(N):
    result+=a_lcm*pow(A[i],Mod-2,Mod)
print(result%1000000007)

Verdicts: Runtime Error

Time Limit Exceeded

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

#from math import gcd
from fractions import gcd

def main():
	n=int(input())
	A=list(map(int,input().split()))
	
	a=1
	for i in A:
		a=a*i//gcd(a, i)
	ans=0
	for i in A:
		ans+=(a//i)
		ans%=mod
	print(ans)
	
	
	
	
	
	


if __name__ == "__main__":
	main()


import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

#from math import gcd
from fractions import gcd

def main():
	n=int(input())
	A=list(map(int,input().split()))
	B=set(A)
	A=list(A)
	A.sort(reverse=True)
	a=1
	ans=0
	for i in A:
		g=gcd(a, i)
		ans *=i//g
		a=a*i//gcd(a, i)
		ans+=a//i
		ans%=mod
	
	
	
	
	print(ans)
	
	
	
	
	
	


if __name__ == "__main__":
	main()


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

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
	lcm %= MOD
ans = 0
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)

print(ans%MOD)


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

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
lcm = MOD
ans = 0
for i in A:
    ans += lcm//i
    ans %= MOD
print(ans)


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

MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lcm = 1
for i in A:
    lcm = (lcm*i)//gcd(lcm,i)
lcm %= MOD
ans = 0
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)

print(ans%MOD)


Verdicts: Time Limit Exceeded

Time Limit Exceeded

Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd

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

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

lcm_a = 1

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

B = np.array([])
for i in range(N):
    B = np.append(B,lcm_a//A[i])

mod = int(1e9+7)
print(int((np.sum(B)%mod)))

from fractions import gcd

import numpy as np 

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

lcm_a = 1

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

B = np.array([])
for i in range(N):
    B = np.append(B,lcm_a//A[i])

mod = int(1e9+7)
print((np.sum(B)%mod)//1)

import numpy as np 

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

lcm_a = 1

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

B = np.array([])
for i in range(N):
    B = np.append(B,lcm_a//A[i])

mod = int(1e9+7)
print(np.sum(B)%mod//1)


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

lcm_a = 1

for i in A:
    lcm_a = lcm(lcm_a,i)

ans = 0
for i in A:
    ans +=lcm_a//i 
    
print(ans%int(1e9+7))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def gcd(x, y):
    x = x % y
    if x == 0:
        return y
    return gcd(y, x)

def lcm(x, y):
    return x // gcd(x, y) * y
n = int(input())
a = list(map(int, input().split(' ')))
l = 1
for ai in a:
    l = lcm(l, ai)
print(l)
mod = 1000000007
ans = 0
for ai in a:
    ans += l // ai
ans %= mod
print(ans)


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

def lcm(x, y):
    return x // gcd(x, y) * y
n = int(input())
a = list(map(int, input().split(' ')))
l = 1
for ai in a:
    l = lcm(l, ai)
mod = 1000000007
ans = 0
for ai in a:
    ans += l // ai
ans %= mod
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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 = []
for i in range(N):
    B.append(ans//a[i])

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

def gcd(a,b):
    while b!=0:
        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()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // gcd(ans, a[i])

B = []
for i in range(N):
    B.append(ans//a[i])

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

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(input().split()))
s=1
for a in A:
    s=lcm(s,i)
ans=0
for a in A:
    ans+=s//i
print(ans%(10**9+7))

def gcd(a,b):
    if a>b:
        return gcd(b,a)
    if a==0:
        return b
    return gcd(b-a*(b//a),a)
def lcm(x,y):
    return (x*y)//gcd(x,y)
N=int(input())
A=list(map(int,input().split()))
s=1
for a in A:
    s=lcm(s,a)
ans=0
for a in A:
    ans+=s//a
print(ans%(10**9+7))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def gcd(m, n):
    while n:
        m, n = n, m % n
    return m

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

L=1
for i in range(n):
  L = lcm(l, a[i])
ans = 0
L %= mod
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)


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

def gcd(m, n):
    while n:
        m, n = n, m % n
    return m

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

L = 1
for i in range(n):
  L = lcm(L, a[i])
ans = 0
L %= mod
for i in range(n):
  ans += L * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
LCM = 1
for i in A:
    GCD = gcd(LCM,i)
    LCM = LCM*i//GCD
ans = 0
for i in A:
    ans += (LCM//i)%mod
print(ans)

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
LCM = A[0]
GCD = A[0]
for i in A:
    GCD = gcd(LCM,i)
    LCM = LCM*i//GCD
ans = 0
for i in A:
    ans += (LCM//i)%mod
print(ans)

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
LCM = 1
for i in A:
    GCD = gcd(LCM,i)
    LCM = LCM*i//GCD
ans = 0
for i in A:
    ans = (ans+LCM//i)%mod
print(ans)

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
LCM = 1
for i in A:
    GCD = gcd(LCM,i)
    LCM = LCM*i//GCD
ans = 0
for i in A:
    ans = (ans+LCM//i)%mod
print(ans)

N = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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


def lcmlist(lista):
    if len(lista) == 1:
        return lista[0]
    else:
        from functools import reduce
        return reduce(lcm,lista)
LCM = lcmlist(A)
ans = 0
for i in A:
    ans += LCM//i
print(ans%mod)

Verdicts: Wrong Answer

Wrong Answer

Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
N = int(input())
A = list(map(int, input().split()))

import numpy as np

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

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i])
an = 0
MOD = 10**9+7

for x in A:
  //print(g,g//x)
  an += g//x
  an %= MOD

print(an)

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

#N = 10000


MOD = 10**9+7

sm = 0
for x in A:
  sm += pow(x,MOD-2,MOD)
  sm %= MOD

def gcd(x: int, y: int):
  while(y!=0):
    tmp = x%y
    x = y
    y = tmp
  return x

g = 1
for i in range(N):
  g = g * A[i] // gcd(g, A[i]) #pow(gcd(g, A[i]), MOD-2, MOD)
  #print(g)

an = g * sm % MOD

'''
for x in A:
  #print(g,g//x)
  an += g*pow(x,MOD-2,MOD)
  an %= MOD
  print(g,g//x,an)
'''

print(an)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
def main():
  def sieve(n):
    prime=[]
    limit=n*0.5
    data=[i+1 for i in range(1,n)]
    while True:
        p=data[0]
        if limit<=p:
            return prime+data
        prime.append(p)
        data=[e for e in data if e%p!=0]
        
  prime=sieve(1000)
  import sys
  import numpy as np
  input=sys.stdin.readline
  mod=10**9+7
  
  n=int(input())
  num=np.array(list(map(int,input().split())))
  
  lcm=1
  num_copy=num.copy()
  for p in prime:
    while np.any(num%p==0):
      num[num%p==0]//=p
      lcm *= p
      lcm %= mod
      
  #print(lcm,num_copy)
  ans=0
  for i in range(n):
    ans += lcm * pow(num_copy[i] ,mod-2 ,mod)
    ans %= mod 
    #print(ans)
  print(ans)
  
if  __name__=='__main__':
  main()

def main():
  def sieve(n):
    prime=[]
    limit=n*0.5
    data=[i+1 for i in range(1,n)]
    p_append=prime.append
    while True:
        p=data[0]
        if limit<=p:
            return prime+data
        p_append(p)
        data=[e for e in data if e%p!=0]
        
  prime=sieve(1000)
  import sys
  import numpy as np
  input=sys.stdin.readline
  mod=10**9+7
  
  n=int(input())
  num=list(map(int,input().split()))
  num_copy=np.array(num)
  
  lcm=1
  for p in prime:
    while np.any(num_copy%p==0):
      num_copy[num_copy%p==0]//=p
      lcm *= p
      lcm %= mod
  
  for i in set(num_copy.tolist()):
    lcm *= i
    lcm %= mod
    
  #print(lcm,num)
  ans=0
  for i in range(n):
    ans += lcm * pow(num[i] ,mod-2 ,mod)
    ans %= mod 
    #print(ans)
  print(ans)
  
if  __name__=='__main__':
  main()

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b)//gcd(a, b)
N = int(input())
A = list(map(int,input().split()))
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x)
for x in A:
    ans = (ans + l/x)
    if ans > mod: ans %= MOD
print(ans)



def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b) //gcd(a, b)
N = int(input())
A = list(map(int,input().split()))
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x) % mod
for x in A:
    ans = (ans + l/x) % mod
print(ans)


def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b) //gcd(a, b)
N = int(input())
A = list(map(int,input().split()))
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x)
for x in A:
    ans = (ans + l/x) % mod
print(ans)


import math
def lcm(a, b):
    return (a*b) //math.gcd(a, b)
N = int(input())
A = map(int, input().split())
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x) % mod
for x in A:
    ans = (ans + l/x) % mod
print(ans)

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

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

A = []

N = int(raw_input())
A = map(int, raw_input().split())
l = 1
for x in A:
    l = lcm(l, x)
ans, mod = 0, 1000000007
for x in A:
    ans = (ans + l/x)
    if ans > mod: ans = ans % mod
print(ans)



def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b)//gcd(a, b)
N = int(input())
A = map(int, input().split())
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x)
for x in A:
    ans = (ans + l//x) % mod
print(ans)



def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)
def lcm(a, b):
    return (a*b)//gcd(a, b)
N = int(input())
A = map(int, input().split())
l = 1
ans, mod = 0, 1000000007
for x in A:
    l = lcm(l, x) % mod
for x in A:
    ans = (ans + l//x) % mod
print(ans)

def gcd(a,b):
    if not b: return a
    return gcd(b,a%b)

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

N = int(input())
A = list(map(int,input().split()))
l = 1
ans, mod = 0, 1000000007

for x in A:
    l = lcm(l, x)

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


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def gcd(a,b):
    while b!=0:
        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()))

lcm_A = 1
for i in range(N):
    lcm_A = lcm(lcm_A, A[i])
    
ans = 0
for i in range(N):
    ans += lcm_A // A[i]

mod = 10**9+7
print(ans & mod)

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

lcm_A = 1
for i in range(N):
    lcm_A = lcm(lcm_A, A[i])
    
ans = 0
for i in range(N):
    ans += lcm_A // A[i]

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


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd
def lcm(a, b):
    return a // gcd(a, b) * b

def main():
    num = int(input())
    d = list(map(int, input().split()))
    k = 1
    MOD = 1000000007
    ans = 0
    for a in d:
        k = lcm(k, a)
    for a in d:
        ans += k // a % MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()


from fractions import gcd
from sys import stdin

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

def main():
    readline = stdin.readline
    num = int(readline())
    d = list(map(int, readline().split()))
    k = 1
    MOD = 1000000007
    ans = 0
    for a in d:
        k = lcm(k, a)
    for a in d:
        ans += k // a % MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()

from sys import stdin

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

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

readline = stdin.readline
num = int(readline())
d = list(map(int, readline().split()))
k = 1
MOD = 1000000007
ans = 0
for a in d:
    k = lcm(k, a)
for a in d:
    ans += k // a
print(ans % MOD)

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
import sys
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

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

MOD = 10**9+7
n = int(input())
n, *a = map(int, sys.stdin.buffer.read().split())
l = a[0]
for x in a[1:]:
    l = lcm(x, l)

l %= MOD

ans = 0
for x in a:
    ans += l*pow(x, MOD-2, MOD)%MOD
print(ans%MOD)


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

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

MOD = 10**9+7
n, *a = map(int, sys.stdin.buffer.read().split())
l = a[0]
for x in a[1:]:
    l = lcm(x, l)
l %= MOD

ans = 0
for x in a:
    ans = (ans + l * pow(x, MOD-2, MOD)%MOD)%MOD
print(ans)


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

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

MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for x in a[1:]:
    l = lcm(x, l)
l %= MOD

ans = 0
for x in a:
    ans = (ans + l * pow(x, MOD-2, MOD)%MOD)%MOD
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
s = list(map(int,input().split()))
ans = 0
mod = int(1e9+7)
import fractions

#   while b != 0:
#     a, b = b, a % b
#   return a

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

g = 1
for i in range(n):
    g = lcm(g, s[i])
for i in range(n):
    ans += g // s[i] % mod
print(ans%mod)



n = int(input())
s = list(map(int,input().split()))
ans = 0
mod = int(1e9+7)
def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a
def lcm(a,b):
    return a // gcd(a,b)

g = 1
for i in range(n):
    g = lcm(g, s[i])
for i in range(n):
    ans += g // s[i]
print(ans%mod)


n = int(input())
s = list(map(int,input().split()))
ans = 0
mod = int(1e9+7)
def gcd(a,b):
  while b != 0:
    a, b = b, a % b
  return a
def lcm(a,b):
    return a // gcd(a,b) * b

g = 1
for i in range(n):
    g = lcm(g, s[i])
for i in range(n):
    ans += g // s[i]
print(ans%mod)


Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main(){
    ll MOD = 1000000007;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> A(N,0);
    REP(i,N){
        cin >> A[i];}
    ll c = A[0];
    for (auto e: A){
        c = lcm(e,c);
    }
    ll ans = 0;
    for (auto e: A){
        ans += c/e;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


N = int(input())
A = list(map(int,input().split()))
MOD = 10**9 + 7
t = A[0]

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)
for e in A:
    t = lcm(e,t)

ans = 0
for e in A:
    ans += t//e

print(ans%MOD)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
from functools import reduce

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

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

MOD = 10**9+7
lcm_val = lcm_list(A)
diff = [lcm_val // a for a in A]
print(sum(diff)%MOD)


class PrimeOptimizer:
    def __init__(self, MAX_NUM=10**3):
        is_prime = [True] * MAX_NUM
        is_prime[0] = False
        is_prime[1] = False
        primes = []
        for i in range(MAX_NUM):
            if is_prime[i]:
                primes.append(i)
                for j in range(2*i, MAX_NUM, i):
                    is_prime[j] = False
        self.primes = primes

    def prime_factorization(self, x):
        res = {}
        for prime in self.primes:
            while x % prime == 0:
                if not prime in res:
                    res[prime] = 0
                res[prime] += 1
                x //= prime
        if x > 1:
            res[x] = 1
        return res

MOD = 10**9+7

def mod_pow(p, q):
    res = 1
    while q:
        if q & 1:
            res = (res * p) % MOD
        p = (p * p) % MOD
        q //= 2
    return res

def mod_inv(p):
    return mod_pow(p, MOD - 2)

def solve(n, a):
    primeOpt = PrimeOptimizer()
    D = {}
    for i in range(n):
        prime_num_mapping = primeOpt.prime_factorization(a[i])
        for prime, num in prime_num_mapping.items():
            if not prime in D:
                D[prime] = 0
            D[prime] = max(D[prime], num)
    L = 1
    for prime, num in D.items():
        L = (L * mod_pow(prime, num)) % MOD
    res = sum([L * mod_inv(x) % MOD for x in a])
    return res % MOD

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

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
import sys
input = sys.stdin.buffer.readline
import fractions

def main():
    N = int(input())
    a = list(map(int,input().split()))
    MOD = 10**9+7
            
    def lcm(x,y):
        return((x*y)//fractions.gcd(x,y))
        
    ans = 0
    l0 = 1
    for num in a:
        l1 = lcm(l0,num)
        ans = (ans*(l1//l0)+l1//num)%MOD
        l0 = l1
        
    print(ans)

if __name__ == "__main__":
    main()

import sys
input = sys.stdin.buffer.readline
import fractions
from functools import reduce

def main():
    N = int(input())
    a = list(map(int,input().split()))
    MOD = 10**9+7
            
    def lcm(x,y):
        return((x*y)//fractions.gcd(x,y))
        
    l = reduce(lcm,a)
    ans = 0
    for num in a:
        ans += l//num
        ans %= MOD
    
    print(ans)

if __name__ == "__main__":
    main()

import sys
input = sys.stdin.buffer.readline
import fractions
from functools import reduce

def main():
    N = int(input())
    a = list(map(int,input().split()))
    MOD = 10**9+7
            
    def lcm(x,y):
        return((x*y)//fractions.gcd(x,y))
        
    l = reduce(lcm,a)
    ans = 0
    for num in a:
        ans += l//num
    
    print(ans)

if __name__ == "__main__":
    main()

import sys
input = sys.stdin.buffer.readline
import fractions

def main():
    N = int(input())
    a = list(map(int,input().split()))
    MOD = 10**9+7
            
    def lcm(x,y):
        return((x*y)//fractions.gcd(x,y))
        
    ans = 0
    l = [1]
    for num in a:
        l.append(lcm(l[-1],num))
        ans = (ans*(l[-1]//l[-2])+l[-1]//num)%MOD
        
    print(ans)

if __name__ == "__main__":
    main()

import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    N = int(input())
    a = list(map(int,input().split()))
    MOD = 10**9+7
    
    d = defaultdict(int)
    
    for x in a:
        num = x
        count = 0
        while num%2 == 0:
            num //= 2
            count += 1
        d[2] = max(d[2],count)
        for i in range(3,int(x**(1/2))+1,2):
            if num%i == 0:
                count = 0
                while num%i == 0:
                    num //= i
                    count += 1
                d[i] = max(d[i],count)
        if num != 1:
            d[num] = max(d[num],1)

    base = 1
    for x,y in d.items():
        base *= pow(x,y,MOD)
        base %= MOD
        
    s = 0
    for num in a:
        inv_a = pow(num,MOD-2,MOD)
        s += inv_a
        s %= MOD
        
    print((base*s)%MOD)

if __name__ == "__main__":
    main()


Verdicts: Time Limit Exceeded

Time Limit Exceeded

Wrong Answer

Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
from functools import reduce

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

p = 10**9+7
ans = 0

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

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

lcm = lcm_list(A)

for i in A:
    ans += lcm // i % p

print(ans%p)

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)


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)

import collections

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):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = sieve(10**3)

def primeFactorization(n):
    ans = []
    temp = n
    for p in primes:
        while temp%p == 0:
            ans.append(p)
            temp //= p
    if temp > 1:
        ans.append(temp)
    return collections.Counter(ans)

AFactorized = list(map(primeFactorization, A))

lcm = collections.Counter()
for a in AFactorized:
    for p, n in a.items():
        lcm[p] = max(lcm[p], n)

lcm_val = 1
for p, n in lcm.items():
    lcm_val *= pow(p, n, mod)

ans = 0
for a in A:
    ans += lcm_val * pow(a, mod-2, mod)
    ans %= mod

print(ans)

Verdicts: Time Limit Exceeded

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from functools import reduce

def gcd(x, y):
    y, x = sorted([x, y])
    while True:
        r = x % y
        if r == 0:
            print(x, y, r)
            return r
        else:
            print(x, y, r)
            x, y = y, r

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

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

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

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

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)

import fractions
from functools import reduce

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

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

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

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)

from functools import reduce

def gcd(x, y):
    y, x = sorted([x, y])
    while True:
        r = x % y
        if r == 0:
            # print(x, y, r)
            return y
        else:
            # print(x, y, r)
            x, y = y, r

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

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

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

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

Verdicts: Runtime Error

Runtime Error

Time Limit Exceeded

Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
#include <bits/stdc++.h>

#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double

#define ss second





#define all(v) v.begin(),v.end()


using namespace std;

int inf = 1e18;
const int N = 5e5+5;
int mod = 1e9+7;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       unordered_map<int,int> mp;
       int arr[n];
       rep(i,0,n)
       cin>>arr[i];
       rep(i,0,n)
       {
           int ct = 0;
           int x = arr[i];
           for(int i=2;i*i<=x;++i)
           {

               if(x%i==0)
               {
                  ct = 0;
                 while(x%i==0)
                 {
                     ct++;
                     x/=i;
                 }
                 mp[i]= max(mp[i],ct);mp[i]= max(mp[i],ct);
               }

           }
           if(x!=1)
            mp[x] = max(mp[x],1LL);
       }
       int lcm = 1;
       for(auto x:mp)
        lcm = (lcm*powmod(x.ff,x.ss))%mod;
        int ans = 0;
        rep(i,0,n)
       {
           ans = (ans + (lcm*powmod(arr[i],mod-2))%mod)%mod;
       }
        cout<<ans<<el;
    }


        return 0;
    }


def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(arr):
  ans = 1
  for i in arr:
    ans = (ans*i)//gcd(ans,i)
  return ans
n = int(input())
arr = list(map(int,input().split())) #list(map(int, input().split()))
l = lcm(arr)
ans = 0;
for i in arr:
  ans+= l//i
print(ans%(10**9+7))


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd

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

N = int(input())
A = tuple(map(int,input().split(" ")))
g = lcm(A)
ans = 0
mod = 10**9+7

for i in A:
    ans += (g//i)%(mod)

print(ans%mod)

from fractions import gcd
N = int(input())
A = [0 for _ in range(N)]
g = 0
for i,a in enumerate(map(int,input().split(" "))):
    A[i] = a
    if i == 0:
        g = a
    g = g*a//gcd(a,g)
ans = 0
A = tuple(A)
for a in A:
    ans += g//a
    ans %= (10**9+7)
print(ans)

from fractions import gcd

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

N = int(input())
A = list(map(int,input().split(" ")))
g = lcm(A)
ans = 0
mod = 10**9+7

for i in A:
    ans += (g//i)%(mod)

print(ans%mod)

from fractions import gcd

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

N = int(input())
A = tuple(map(int,input().split(" ")))
g = lcm(A)
ans = 0
for i in A:
    ans += g//i
    ans %= (10**9+7)

print(ans)

from fractions import gcd

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

N = int(input())
A = tuple(map(int,input().split(" ")))
g = lcm(A)
ans = 0
mod = 10**9+7

for i in A:
    ans += (g//i)%(mod)

print(ans)

from fractions import gcd
N = int(input())
A = tuple(map(int,input().split(" ")))
g = A[0]
l = 1
for i in range(N):
    g = g*A[i]//gcd(A[i],g)
ans = 0
for i in range(N):
    ans += g//A[i]
    ans %= (10**9+7)
print(ans)

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

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l//A[i]
    ans %= mod

print(ans)

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

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

N = int(input())
A = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l//i
    ans %= mod

print(ans)

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 = tuple(map(int,input().split(" ")))
ans = 0
mod = 10**9+7
l = 1
for i in range(N):
    l = lcm(l,A[i])
l %= mod

for i in A:
    ans += l*pow(i,mod-2,mod)
    ans %= mod

print(ans)

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Wrong Answer

Time Limit Exceeded

Runtime Error

Wrong Answer

Accepted