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 = list(map(int,input().split()))
b = sorted(list(set(a)))
P = 10 ** 9 + 7
p = P

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

M = b[0]
for i in range(1, n):
    M = M * b[i] // gcd(b[i], M)

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

print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
mod = (10e9 + 7)
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)%mod
    return sum%mod
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 % mod

print(int(ans))

Submission status: Runtime Error

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

for item in a:
	xx = (xx*item)//math.gcd(xx,item)
sum=0
for item in a:
	sum += (xx/item)

ANS=(sum%1000000007)
print(int(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])

B = list(map(lambda x: int(ans/x % 1000000007), A))

print(sum(B) % 1000000007)

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(input())
l=list(map(int,input().split()))
b=0
c=0
for i in range(n):
    if (i==0):
        b=l[i]
    else:
        b=b*l[i]//gcd(l[i],b)
for i in range(n):
    c+=b//l[i]
print(c%1000000007)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
mod = (10e9 + 7)
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)%mod
        print(lcm/a, int(lcm/a)%mod) 
    return sum%mod
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) 
print(lcm)


ans = inverse_sum(A,lcm )
#print(ans)
ans = ans % mod

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
sosu = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
l = A[0]
for i in range(1, N):
    l = lcm(l, A[i])
ans = 0
for i in range(N):
    ans += l // A[i]
    ans %= sosu
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

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

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions

N = int(input())

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

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

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

l = lcm(*A)
num=0
for a in A:
  num += l/a
print(int(num % (10e9 +7)))

Submission status: Runtime Error

Solution code:

import functools as ft
#import math as ft


prime = 10**9+7

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

an.sort()


lcm_ = 1
for a in an :
    lcm_ = a*lcm_//ft.gcd(a,lcm_)
#    print(lcm_)
    
ans = 0
bn = [0]*n
for i, a in enumerate(an):
    t = lcm_//a
    ans += t 
    ans %= prime

print(ans)

Submission status: Runtime Error

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

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

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

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

for i in range(N):
    res += l//A[i]

print(res % 1000000007)

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, pow(b,mod-2,mod))
lcm = A[0] * A[1] // fractions.gcd(A[0],A[1])
for i in range(2,N):
    lcm = div((lcm * A[i]),fractions.gcd(lcm,A[i]))
ans = 0
for i in range(N):
    b = div(lcm,A[i])
    ans += b 
    ans %= mod 
    #print(ans)
#print(lcm)
print(ans)

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
    ans += lcm_current // a[i]
    ans %= mod
print(ans % mod)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

n=int(input())
a=list(map(int, input().split()))
A=lcm(a)
ans=0

for i in a:
    ans+=A/i

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

Submission status: Runtime Error

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
gcd_n = a[0]
for i in range(1, n):
    gcd_n = gcd_n * a[i] // fractions.gcd(gcd_n, a[i])

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

print(int(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
import fractions
a = list(map(int, input().split()))
print(a)
lcm = a[0]
for i in range(1, N):
    lcm = int(lcm * a[i] / fractions.gcd(lcm, a[i]))

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

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;
#define MOD 1000000007


int gcm(int x,int y){
  while (y>0){
    int temp=y;
    y=x%y;
    x=temp;
  }
  return x;
}

int lcm(int x,int y){
  return x/gcm(x,y)*y;
}


int main(){
  int n;
  cin>>n;
  unsigned int a[n];
  unsigned int a_lcm=1;
  for(int i=0;i<n;i++){
    cin >> a[i];
    a_lcm=lcm(a_lcm,a[i]);
  }
  unsigned int count=0;
  for(int i=0;i<n;i++){
    count+=(a_lcm/a[i])%MOD;
    count%=MOD;
  }
  cout<<count<<endl;
}

Submission status: Runtime Error

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

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm_list(As)
As = np.array(As)
b = np.array([lcm]*n)
c = b / As
print(int(round(np.sum(c)))  % mod)

Submission status: Runtime Error

Solution code:
import fractions
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(map(int,input().split()))
mod=10**9+7
ans=0
m=1
k=0
S=1
for i in range(n):
    m=lcm(m,A[i])
    k+=1/A[i]
print(int(m*k%mod))

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
n = int(input())
a = list(map(int, input().split()))
def lcm(a, b):
    return (a * b) // gcd(a, b)
m = 1
for x in a:
    m = lcm(m, x)
# print(m)
MOD = 1000000007
ans = 0
for x in a:
    b = m / x
    ans = (ans + b) % MOD
print(math.floor(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

a = 0
for i in range(N):
  a += int(lcm/lst[i])
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
import fractions
a = list(map(int, input().split()))
print(lcm)
lcm = a[0]
for i in range(1, N):
    lcm = int(lcm * a[i] / fractions.gcd(lcm, a[i]))

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

Submission status: Runtime Error

Solution code:
import math

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

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

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

print(res % 1000000007)

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:
  if i==0:continue
  ans=ans+(lcm/i)
  ans=ans%mod
ans=ans%mod
print(int(ans))

Submission status: Runtime Error

Solution code:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

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

kobai=1

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

sumN=0

try:
    kobai/2
except:
    pass
    #print(-1)
    #exit()

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 math
N = int(input())
list_number = list(map(int,input().split(" ")))
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)
number_max = lcm_list(list_number)
newlist = list(map(lambda x: number_max // x, list_number))
print(sum(newlist) % 1000000007)

Submission status: Runtime Error

Solution code:
def lcm_for_list(numbers):
    from functools import reduce
    return reduce(lcm, numbers, 1)
 
def lcm(x, y):
    from fractions import gcd  # for Ver.3.4 or lower.
    return (x * y) // gcd(x, y)

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

Submission status: Runtime Error

Solution code:
import fractions
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(map(int,input().split()))
mod=10**9+7
ans=0
m=1
k=0
S=1
for i in range(n):
    m=lcm(m,A[i])
    k+=1/A[i]
print(m*k%mod)

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(input())
c=[]
c=list(map(int,input().split()))


v=[]
if len(c)==0:
  print(0)

elif len(c)==1:
  print(c[0])
elif len(c)==2:
  q=gcd(c[0],c[1])
  lcm=int(c[0]*c[1]/q)
  v=sum([int(lcm/c[0]),int(lcm/c[1])])
  print(v% (pow(10,9)+7))
else:
  q=gcd(c[0],c[1])
  lcm=int(c[0]*c[1]/q)
  for i in range(2,n):
    lcm=int(lcm*c[i]/(gcd(lcm,c[i])))
  
  for i in range(n):
    v.append(int(lcm/c[i]))
  g=sum(v)
  print(g % (pow(10,9)+7))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

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

lcm_a = lcm_list(a)

b = [lcm_a//a[i] for i in range(n)]

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

Submission status: Runtime Error

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

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm_list(As)
As = np.array(As)
b = np.array([lcm]*n)
c = b / As
print(int(round(np.sum(c) % mod)))

Submission status: Runtime Error

Solution code:
from functools import reduce

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

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

def gcd_all(a_list):
  a = a_list[0]
  for i in range(len(a_list)-1):
    num = gcd(a, a_list[i+1])
    a = num
  return a
  
def lcm_all(a_list):
  a = a_list[0]
  for i in range(len(a_list)-1):
    num = lcm(a, a_list[i+1])
    a = num
  return a
mod = 10**9+7
N = int(input())
a_list = list(map(int,input().split()))
lcm = lcm_all(a_list)
b_list = [0]*N
for i in range(len(b_list)):
  b_list[i] = lcm/a_list[i]
print(int(sum(b_list) % mod))

Submission status: Runtime Error

Solution code:
from math import gcd

n = int(input())

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


def find_lcm(x, y):

    return x * y // gcd(x, y)


if len(l) > 1:
    num1 = l[0]
    num2 = l[1]
    lcm = find_lcm(num1, num2)

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

result = 0

for i in l:
    s = lcm / i
    result += s

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

print(int(result))

Submission status: Runtime Error

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

def saisho_ko_baisu(A,B):
    # A < B
    x = A*B
    r = B%A
    while r!=0:
        B = A
        A = r
        r = B%A
    return x//A

A.sort()
tmp = saisho_ko_baisu(A[0], A[1])
for i in range(2,N):
    if tmp % A[i] != 0:
        tmp = saisho_ko_baisu(min([tmp, A[i]]), max([tmp, A[i]]))
res = 0
for a in A:
    res += tmp//a

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

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
  
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()))
gcd_n = a[0]
for i in range(1, n):
    gcd_n = gcd_n * a[i] // fractions.gcd(gcd_n, a[i])

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

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

B = list(map(lambda x: int(ans/x), A))

print(sum(B) % 1000000007)

Submission status: Runtime Error

Solution code:
from math import gcd
from collections import Counter

n = int(input().strip())
A = [int(s) for s in input().strip().split()]
M = 10 ** 9 + 7

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def lcm(a, b):
    return (a * b * modinv(gcd(a, b), M)) % M

factors = Counter()
for a in A:
    d = Counter()
    while a % 2 == 0:
        d[2] += 1
        a //= 2
    for i in range(3, int(a ** 0.5) + 1, 2):
        while a % i == 0:
            d[i] += 1
            a //= i
        if a == 1:
            break
    if a > 1:
        d[a] += 1
    factors |= d
# print(factors)
m = 1
for k, v in factors.items():
    m = (m * pow(k, v, M)) % M

result = 0
for a in A:
    result = (result + m * modinv(a, M)) % M
print(result)

Submission status: Runtime Error

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

sys.setrecursionlimit(2147483647)

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:
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 = int(sum % 1000000007)
print(int(sum))

Submission status: Runtime Error

Solution code:
import sys,fractions
sys.setrecursionlimit(10**5)
def input():
    return sys.stdin.readline()[:-1]

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

u = 10**9+7

from functools import reduce

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

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

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

G = l[0]
for i in range(1,N):
    G = fractions.gcd(G,l[i])
    if G==1:
        break
gcd = G
L = [l[i]//gcd for i in range(N)]
lcm = lcm_list(L)

# print(lcm,gcd,'aaa')
ANS = 0
for i in range(N):
    elm = L[i]
    ANS += (lcm/elm)
    ANS %= u
print(ANS)

Submission status: Runtime Error

Solution code:
mod = 1000000007

def add(a, b):
    return (a + b) % mod

n = int(input())
a = list(map(int,input().split()))
ans = a[0]
ans_ans = 0
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for j in range(0, n):
  b = ans // a[j]
  ans_ans+=b
  #ans_ans = add(ans_ans,b)
  
print(ans_ans % mod)

Submission status: Runtime Error

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

import math
from functools import reduce

def lcm_base(x, y):
  return (x * y) // math.gcd(x, y)
def lcm(*numbers):
  return reduce(lcm_base, numbers, 1)
def lcm_list(numbers): # これに数字のlistを渡せばOK
  return reduce(lcm_base, numbers, 1)

l = lcm_list(A)
B = []
for ai in A:
  B.append(int(l/ai))

ans = 0
for bi in B:
  ans = (ans + bi) % mod

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
N = int(input())
lst = list(map(int, input().split()))
lcm = lcm_list(lst)

a = 0
for i in range(N):
  a += int(lcm/lst[i])
print(a)

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

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:
from functools import reduce
from fractions import gcd
import numpy as np

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm_list(As)
As = np.array(As)
b = np.array([lcm]*n)
c = b / As
print(int(np.sum(c) % 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:
  if i==0:continue
  ans=ans+(lcm/i)
  ans=ans%mod
ans=ans%mod
print(int(ans))

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 // fractions.gcd(ans, As[i])) * 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 math import gcd
N = int(input())
A = [int(i) for i in input().split()]
lcd = A[0]
for i in A:
    lcd = lcd * i // gcd(lcd,i)
ans = 0
for i in A:
    ans += lcd // i
print(ans% (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]
 b%=(10**9+7)
print(int(b))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, raverse=True)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
mod = 7 + 10 ** 9
lcm = lcm(*A)
ans = 0
for i in A:
    ans += lcm // i
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
mod = 1e9 + 7;

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

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

l = A[0]
ll = l
for i in range(1, N):
  l = l * A[i] // gcd(l, A[i])
  if ll > l:
    break
  ll = l

sum = 0
for i in A:
  sum += l / i
  sum %= mod

print(int(sum))

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

d = [0] * (max(A) + 1)
d = {i: 0 for i in range(1, max(A)+1)}
d = defaultdict(int)


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


for a in A:
    for i in range(2, int(a ** 0.5) + 1):
        if a % i == 0:
            cnt = 0
            while a % i == 0:
                cnt += 1
                a //= i
            d[i] = max(d[i], cnt)
    if a != 1:
        d[a] = 1

ans = 0
for a in A:
    tmpD = d.copy()
    pf = prime_factorization(a)
    for k, v in pf:
        tmpD[k] -= v
    b = 1
    for k, v in tmpD.items():
        if v == 0:
            continue
        b *= pow(k, v, mod)
        v %= mod
    ans += b
    ans %= mod

print(ans % mod)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
N = int(input())
lst = list(map(int, input().split()))
lcm = lcm_list(lst)

a = 0
for i in range(N):
  a += int(lcm/lst[i])
print(a)

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(map(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 functools import reduce
from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

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

lcm_a = lcm_list(a)

b = [lcm_a//a[i] for i in range(n)]

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

Submission status: Runtime Error

Solution code:
import numpy as np
_,p = [list(map(int, s.split())) for s in open(0)]
lcm = np.lcm.reduce(p)
x = 1e9 + 7
ans = 0
for q in p:
    ans += int((lcm/q)%x)
print(int(ans%x))

Submission status: Runtime Error

Solution code:
def lcm_for_list(numbers):
    from functools import reduce
    return reduce(lcm, numbers, 1)
 
def lcm(x, y):
    from fractions import gcd  # for Ver.3.4 or lower.
    return (x * y) // gcd(x, y)

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

Submission status: Runtime Error

Solution code:
from math import gcd
n=int(input())
c=list(map(int,input().split()))
q=gcd(c[0],c[1])
lcm=int(c[0]*c[1]/q)
v=[]
if len(c)==1:
  print(c[0])
elif len(c)==2:
  v=sum([int(lcm/c[0]),int(lcm/c[1])])
  print(v% (pow(10,9)+7))
else:
  for i in range(2,n):
    lcm=int(lcm*c[i]/(gcd(lcm,c[i])))
  
  for i in range(n):
    v.append(int(lcm/c[i]))
  g=sum(v)
  print(g % (pow(10,9)+7))

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 = list(map(lambda x: int(ans/x), A))

print(sum(B) % 1000000007)

Submission status: Runtime Error

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

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)
    b_sum %= (10**9 + 7)

print(b_sum)

Submission status: Runtime Error

Solution code:
def find_lcm(num1, num2): 
    if(num1>num2): 
        num = num1 
        den = num2 
    else: 
        num = num2 
        den = num1 
    rem = num % den 
    while(rem != 0): 
        num = den 
        den = rem 
        rem = num % den 
    gcd = den 
    lcm = int(int(num1 * num2)/int(gcd)) 
    return lcm 
      
    
n = int(input())
l = list(map(int, input().split()))
  
num1 = l[0] 
num2 = l[1] 
lcm = find_lcm(num1, num2) 
  
for i in range(2, len(l)): 
    lcm = find_lcm(lcm, l[i]) 

MOD = 1000000007
# print(LCM)
s = 0


for num in l:
	s = (s + ( lcm//num ))%MOD

print(s)

# 499998500001000000

Submission status: Runtime Error

Solution code:
_,p = [list(map(int, s.split())) for s in open(0)]
lcm = np.lcm.reduce(p)
x = 1e9 + 7
ans = 0
for q in p:
    ans += int((lcm/q)%x)
print(int(ans%x))

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 boost::multiprecision::cpp_int;

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

//最小公倍数
cpp_int lcm(cpp_int a, cpp_int 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;
  }
  cpp_int tmp = lcm(A[0],A[1]);
	for (int i(1);i<N;i++){
    tmp = lcm(tmp,A[i]);
  }
  cpp_int 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:
n = int(input())
a = list(map(int, input().split()))

import numpy as np

a_lcm = np.lcm.reduce(a)

# print(a_lcm)

a_array = np.array(a)

b = a_lcm / a_array

# print(np.sum(b))

ans = int(np.sum(b) % (10**9 + 7))
 
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
import fractions
X1 = A[0]
Y = 1
for i in range(1, N):
    X2 = X1 // fractions.gcd(X1, A[i]) * A[i]
    Y *= int(X2/X1)
    Y += int(X2/A[i])
    Y = Y%(10**9+7)
    X1 = X2
print(Y)

Submission status: Runtime Error

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

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

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


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

mod = 1000000007
ans = 0
for i in A:
    ans = (ans + l/i)%mod

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
def find(a):
    ans = a[0]
    for i in range(1,len(a)):
        ans = (ans*a[i])//(math.gcd(ans,a[i]))
    return ans



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

lcm = find(a)
ans = 0
mod = pow(10,9)+7
for i in a:
        ans = (ans + (lcm//i)%mod)%mod

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

x = 1
for i in range(1, 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))