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

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

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

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

    lcmnum = (lcm(*Al))
    
    
    ans = 0
    for A in Al:
        ans += lcmnum / A
    
    print(ans%(10**9+7))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline


n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
y=0

for x in a:
  if y!=x and l%x!=0:
    g=gcd(l,x)
  y=x

l=lcm(*a)

for x in a:
  ans+=(l//x)%m

print(ans%m)

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

p_L = []
for i in a:
    p_L.append(ans/i)

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

Submission status: Runtime Error

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

def lcm(a, b):
	return a * b // gcd (a, b)
  
N = int(input())

kazu = list(map(int, input().split(' ')))

koubai = 1
for i in range(N):
  
  koubai = lcm(koubai, kazu[i])

yakusu = [int(koubai / n) for n in kazu]

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

Submission status: Runtime Error

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

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

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
k = lcm_list(a)
cnt=0
for i in range(n):
  cnt+=k//a[i]
print(cnt)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000000)

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:
import fractions
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//fractions.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(int(t)%1000000007)

Submission status: Runtime Error

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



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

lcma=lcm(a)
ans=0
for i in range(n):
    ans+=lcma/a[i]
print(int(ans))

Submission status: Runtime Error

Solution code:
mod = 1e9 + 7

def gcd(n, m):
  
  if m > n:
    m, n = n, m
  
  if m == 0:
    return n
  
  r = n % m
  if r == 0:
    return m
  else:
    return gcd(m, r)
  
  
def lcm(n, m)
	return n / gcd(n, m) * m
  
  

def mod_pow(x, n, mod):
  res = 1
  
  while n > 0:
    if n & 1:
      res = res * x % mod
    
    x = x * x % mod
    n = n // 2
    
  return int(res)

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

if n == 1:
  print(1)
else:
  val_lcm = li[0]
  for i in range(1,n-1):
    val_lcm = lcm(li[i],val_lcm)
    
  li2 = []
  for i in range(0,n-1):
    li2.append(val_lcm / li[i])
    
  ans = li2[0]
  for i in range(1, n-1):
    ans = (ans + li2[i]) % mod
  
print(ans)

Submission status: Runtime Error

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

from math import gcd


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

b = [0] * n
b[0], b[1] = a[1] // gcd(a[0], a[1]), a[0] // gcd(a[0], a[1])

for i in range(2, n):
    l = lcm(a[i-1] * b[i-1], a[i])
    b[i] = l // a[i]
    u = (a[i] * b[i]) // (a[i-1] * b[i-1])
    for j in range(i):
        b[j] *= u

ans = sum(b)
print(ans // 1000000007)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

P = 10**9 + 7
N = 1000000
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

_,p = [list(map(int, s.split())) for s in open(0)]
gcd_ = reduce(fractions.gcd, p)
lcm_ = 1
for q in p:
    lcm_ *= inv_t[q]
x = 1e9 + 7
ans = 0
for q in p:
    ans += int((lcm_/q)%x)
print(int(ans%x))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
import fractions
from functools import reduce
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
Z = lcm(A)
ans = sum(Z//a%mod for a in A)%mod
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import math
from functools import reduce
N = int(input().split()[0])
a = [int(i) for i in input().split()]

def lcm(a, b):
    x = a * b
    if a < b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return x / b

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

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

l = lcm(*a)

MOD = 1000000007

ans = np.sum(l / np.array(a))

print(int(ans) % MOD)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fraction
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

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

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
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])

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

print(int(bsum % 1000000007))

Submission status: Runtime Error

Solution code:
import fractions

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


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

lcm_a = lcms(A)

sum_b = sum(sum_b + lcm_a // a) % (10**9 + 7)

print(sum_b)

Submission status: Runtime Error

Solution code:
import numpy as np
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)

n = int(input())
a = [int(i) for i in input().split()]
s = 0
for ai in a:
	s += ai

print((lcm(a)/s) % (10**9+7))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

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

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

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

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

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
    ans %= 1000000007

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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


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

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

Submission status: Runtime Error

Solution code:
import  fractions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

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

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

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


if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions
import sys
from functools import reduce


def gcd_list(numbers):
    lcm = numbers[0]
    for i in range(1, len(numbers)):
        lcm = fractions.gcd(lcm, numbers[i])


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


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


def solve(inp):
    N = int(inp.readline().strip())
    A = list(map(int, inp.readline().strip().split(' ')))

    lcm = lcm_list(A)

    r = 0
    for a in A:
        r = (r + int(lcm / a)) % 1000000007

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

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

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

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

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

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//x)
    ans %= 1000000007

print(ans)

Submission status: Runtime Error

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

import fractions

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

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

b = 0

for i in A:
    b += lcm_list(A)/i
print(int(b)%(10**9+7))

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions

N = int(input())
A = [int(l) for l in 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)

MOD = 1000000007

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

print(int(ans))

Submission status: Runtime Error

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

fac = [1]
inv = [1]

for i in range(1, N + 10) :
	fac.append(fac[-1] * i % MOD)
	inv.append(pow(fac[-1], MOD - 2, MOD))

print(fac[m] * inv[n] * inv[m - n] % MOD)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
		
def lcm(a, b):
	return a * b // gcd(a, b)
		
		
a = 1
for i in range(N):
	a = lcm(A[i], a)

ans = 0
	
for i in range(N):
	ans += a * inv(A[i]) % MOD
	ans %= MOD
	
print(int(ans))

Submission status: Runtime Error

Solution code:
from fractions import gcd

MOD = 1000000000 + 7

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    ans = (ans * (a // g)) % MOD
    l = l * a // g
    ans = (ans + (l / a) % MOD) % MOD
print(int(ans))

Submission status: Runtime Error

Solution code:
input_list=[input() for i in range(2)]
N = int(input_list[0])
A_s = list(map(int,input_list[1].split()))	

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)

M = lcm_list(A_s)
M_sum = sum([int(M/x) for x in A_s])
print(M_sum % (10**9 + 7))

Submission status: Runtime Error

Solution code:
import math

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

ans = 1
for x in A:
    ans = x * ans // math.gcd(ans, x)

B = list(map(lambda x: ans // x, A))
print(int(sum(B)%(math.pow(10,9)+7)))

Submission status: Runtime Error

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

fac = [1]
inv = [1]

for i in range(1, n + 1) :
	fac.append(fac[-1] * i % MOD)
	inv.append(pow(fac[-1], MOD - 2, MOD))

print(fac[m] * inv[n] * inv[m - n] % MOD)

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
		
def lcm(a, b):
	return a * b // gcd(a, b)
		
		
a = 1
for i in range(N):
	a = lcm(A[i], a)

ans = 0
	
for i in range(N):
	ans += a * inv(A[i]) % MOD
	ans %= MOD
	
print(int(ans))

Submission status: Runtime Error

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

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

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa%=mod
    ans%=mod
print(ans)

Submission status: Runtime Error

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

if n==1:
    print(1)
else:
    g=A[0]
    l=A[0]
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
    C=l*(1/B)
    ans=int(C.sum())
    print(int(ans)%mod)

Submission status: Runtime Error

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

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

l = a[0]

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

c = 0  
for i in range(n):
  c += int(l / a[i])
  c %= ((10 ** 9) + 7)

print(str(int(c)))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)

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

import numpy as np
ary = np.array(a)
ary = ans / ary    

for j in range(0, n):
  ans_ans = add(ans_ans,ary[j])
  
print(int(ans_ans))

Submission status: Runtime Error

Solution code:
from fractions import gcd

N = int(input())

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

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

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

Submission status: Runtime Error

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

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

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

lcmAll = lcm2(A[0], A[1])
if N > 2:
    for i in range(2, N):
        lcmAll = lcm2(lcmAll, A[i])

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

print(str(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def GCD(a,b):
    if(b==0):
        return a
    else:
        aa = a%b
        return GCD(b,aa)
    #return b == 0 ? a:GCD(b,a%b)
n = int(input())
mod = 1e9 + 7
a = []
ans = 1

for i in range(n):
    x = int(input())
    a.append(x)
    
    ans = x /GCD(ans,x)*ans
sum = 0
for i in range(n):
    sum = sum+ans/a[i]
    sum = sum%mod
print(sum)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) /math.gcd(x, y)

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

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

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//fractions.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(1000000007%int(t))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll gcd(ll a, ll b){
    if(a == 0 || b == 0){
        return 0;
    }
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


int main(){
    ll N;
    ll a[10100];
    ll b[10100];
    ll c[10100];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    ll x = 1;
    for(int i = 1; i < N; i++){
        ll p = a[i] / gcd(a[0], a[i]);
        c[i] = p;
    }

    for(int i = 1; i < N; i++){
        for(int j = i+1; j < N; j++){
            c[j] = c[j] / gcd(c[i], c[j]);
        }
    }

    b[0] = 1;
    for(int i = 1; i < N; i++){
        b[0] = mul(c[i], b[0]);
    }

    ll res = b[0];
    for(int i = 1; i < N; i++){
        b[i] = mul(mul(b[0], a[0]), mod_inv(a[i]));
        res = add(res, b[i]);
    }

    cout << res << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions
from functools import reduce
N=int(input())
a=list(map(int,input().split()))
ans=0
ansans=0
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

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

kbs=lcm_list(a)
for i in range(0,N):
    ansans+=kbs/a[i]
ans=int(ansans)
print(ans)

Submission status: Runtime Error

Solution code:
import  fructions
from functools import reduce
import sys
input = sys.stdin.readline
def main():
    n=int(input())
    a=list(map(int,input().split()))
    tmp = lcm(*a)
    mod=10**9 + 7
    m=0
    ans=0
    for i,v in enumerate(a):
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

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

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

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


if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

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

mod = 10**9+7

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

def lcm(x, y):
    tmp = modinv(math.gcd(x,y),mod)
    # print(mod)
    return x * y * tmp

l = 1
for k in a:
    l = lcm(l,k)

l = l % mod

mod = 10**9+7
res = 0
for k in a:
    tmp = modinv(k, mod)
    res = (res + l * tmp % mod) % mod

res = res % mod
print(res)

Submission status: Runtime Error

Solution code:
import sys
import math


n = sys.stdin.readline()
a = [int(a) for a in sys.stdin.readline().strip().split(' ')]
v = 1
for m in a:
    v = v * m // math.gcd(v, m)
print(sum([v // m for m in a]) % 1000000007)

Submission status: Runtime Error

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

ans = 0
for i in range(len(A)):
    ans += lcm / 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()))

a = A[0]
for i in range(1, N):
    g = a * A[i] // fractions.gcd(a, A[i])
    a = g
    
b = 0
for i in range(N):
    b = b + g // A[i]

c = b % (1000000007)
print(c)

Submission status: Runtime Error

Solution code:
import math

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

# Aの最小公倍数
ans = 1
for x in A:
    ans = x * ans // math.gcd(ans, x)

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

print(int(sum(B)%(math.pow(10,9)+7)))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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


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

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

Submission status: Runtime Error

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

import numpy as np
import fractions
from functools import reduce

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

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

if n == 1:
  ans = a[0]
else: 
  a_lcm = lcm_list(a)
  a_array = np.array(a)
  b = a_lcm / a_array

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

Submission status: Runtime Error

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

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


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

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

ans = lcm_ * sum_A % mod

print(int(ans % mod))

Submission status: Runtime Error

Solution code:
from functools import reduce
from fractions import gcd
def lcm(x,y):return x*y//gcd(x,y)
def lcmm(l):return reduce(lcm,l)
a=int(input())
b=list(map(int,input().split()))
num=0
c=lcmm(b)
for i in range(a):
    num+=int(int(c/b[i]))
print(num%(10**9+7))

Submission status: Runtime Error

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

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

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

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

lcmAll = lcm2(A[0], A[1])
if N > 2:
    for i in range(2, N):
        lcmAll = lcm2(lcmAll, A[i])

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

print(str(ans))

Submission status: Runtime Error

Solution code:
n = int(input());
a = list(map(int, 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 (str(ans % 1000000007))

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
N = int(input().split()[0])
a = np.array([int(i) for i in input().split()])

def lcm(a, b):
    x = a * b
    if a < b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return x / b

l = np.lcm.reduce(a)

MOD = 1000000007

ans = np.sum(l / a)

print(int(ans) % 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)


lcm = 0

if n > 1:
    for i in range(0, len(l)):
        if i == 0:
            lcm = find_lcm(l[i], l[i+1])
        else:
            lcm = find_lcm(lcm, l[i])
else:
    lcm = l[0]

result = 0

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

result = result % (1000000007)

print(int(result))

Submission status: Runtime Error

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

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)

Z = lcm_list(A)
MOD = 1000000007

cnt = 0
for i in A:
    cnt += Z / i
    cnt = cnt%MOD
print(int(cnt))

Submission status: Runtime Error

Solution code:
from fractions import gcd

N = int(input())

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

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

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

Submission status: Runtime Error

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

import numpy as np
import fractions
from functools import reduce

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

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

if n == 1:
  ans = a[1]
else: 
  a_lcm = lcm_list(a)
  a_array = np.array(a)
  b = a_lcm / a_array

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

Submission status: Runtime Error

Solution code:
import math

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

mod = 10**9+7

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

def lcm(x, y):
    tmp = modinv(math.gcd(x,y),mod)
    # print(mod)
    return ((x * y)  )* tmp

l = 1
for k in a:
    l = lcm(l,k)

l = l % mod

mod = 10**9+7
res = 0
for k in a:
    tmp = modinv(k, mod)
    res = (res + l * tmp % mod) % mod

res = res % mod
print(res)

# print(a)

# ans = 1

# if n == 1:
#     print(1)
#     exit
# elif n == 2:
#     l = lcm(a[0], a[1])
#     print(l//a[0]+ l//a[1])
#     exit

# print(10)

# ans = 1
# for i in range(n):
#     tmp = lcm(l, i)
#     ans/(n-1)
#     l = lcm(l, a[i])

Submission status: Runtime Error

Solution code:
from fractions import gcd

MOD = 1000000000 + 7

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

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    ans = ((ans * a) // g) % MOD
    l = lcm(l, a)
    ans = (ans + (l / a) % MOD) % MOD
print(int(ans))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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


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

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

Submission status: Runtime Error

Solution code:
from math import gcd

n = int(input())

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

lcm = inputs[0]
for i in inputs[1:]:
  lcm = int(lcm*i/gcd(lcm, i))

ans = 0;
lis = []
for i in inputs:
    ans = ans + int(int(lcm/i)%1000000007)
    ans = ans%1000000007;

print(ans)

Submission status: Runtime Error

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

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

p = lcm(A)
#print (p)

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

print (int(sum%mod))

Submission status: Runtime Error

Solution code:
import fractions

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

a = A[0]
for i in range(1, N):
    gcc = a * A[i] // fractions.gcd(a, A[i])
    a = gcc
    
b = 0
for i in range(N):
    b = b + gcc // A[i]

c = b % (1000000007)
print(c)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

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

l = lcm_list(a)
count = 0
for i in range(len(a)):
    count += int(l/a[i])
    count = count % (1000000007)
print(count)

Submission status: Runtime Error

Solution code:
from math import gcd
N = int(input())
A = list(map(int, input().split(' ')))
lcm = A[0]
for i in A[1:]:
    lcm = lcm*i // gcd(lcm, i)

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

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce
N = int(input())
a = [int(x) for x in input().split()]
def lcm_(c,d):
    return (c*d)//fraction.gcd(c,d)

def lcm(a):
    return reduce(lcm_, a, 1)
t = 0
for i in range(N):
    t = t + lcm(a)/a[i]
print(int(t))