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:
'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''
'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''
'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''
'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''
'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
'''
リスト同士の演算
list(map(lambda x, y: x+y, el2, el3))
'''
'''
配列の初期化
配列名=[a]*n+[b]*m
'''
'''
重複
list(set())
２次元配列
list(map(list, set(map(tuple, addition))))
'''
'''
順列
for el in itertools.permutations(配列のパターン):
'''
'''
Decimal()
'''
# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()




from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul
from decimal import *
def gcd(*numbers):
    return reduce(math.gcd, numbers)


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


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)


def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


N = int(stdin.readline().rstrip())
A = [int(s) for s in stdin.readline().rstrip().split()]
res = lcm_list(A)
part = 0
for k in range(len(A)):
    part += res//A[k]
print(part % (10**9+7))

Submission status: Runtime Error

Solution code:

import fractions 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
for i, a in an:
    t = lcm_ // a
    ans += t 
    ans = ans % prime if ans >= prime else ans

print(ans)

Submission status: Runtime Error

Solution code:

from fractions import gcd


n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x = a[0]
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
x
res = 0
for i in range(n):
    res += gcd//a[i]
    res%=mod
print(res)

Submission status: Runtime Error

Solution code:
import fractions
n=int(input())
t=list(map(int,input().split()))
numbers=list(set(t))
for i in range(len(numbers)):
    if i == 0:
        gcd = numbers[i]
        lcm = numbers[i]
    else:
        gcd = fractions.gcd(gcd, numbers[i])
        lcm = (lcm * numbers[i]) // fractions.gcd(lcm, numbers[i])
a=0
mod=10**9+7
for i in range(n):
  a+=lcm/t[i]
  a=a%mod
print(int(a))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
sys.setrecursionlimit(10**8)
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):

    # 最小公倍数
    lcm = np.lcm.reduce(A)
    ans = np.mod(np.sum(lcm//A, dtype=np.int64), MOD)
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np

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

lc = mp.lcm.reduce(a)

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

print(res)

Submission status: Runtime Error

Solution code:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#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;
}

Submission status: Runtime Error

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

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


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

l = [ans for _ in range(N)]
l = np.array(l)/np.array(A)
l = l%(10**9+7)
print(int(l.sum()%(10**9+7)))

Submission status: Runtime Error

Solution code:
from fractions 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:
def getgcd(a, b):
	if b == 0:
		return a
	return getgcd(b, a % b)

def getlcm(a, b):
	return a / getgcd(a, b) * b

N = int(input())
arr = list(map(int, input().split()))
lcm = 1
for i in range(0, N):
	lcm = getlcm(lcm, arr[i])

ans = 0
MOD = 1000000007
for i in range(0, N):
	ans += lcm // arr[i]
	ans %= MOD

print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions

#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))
    kobai = kobai * a // fractions.gcd(kobai, a)

print(kobai/2)

Submission status: Runtime Error

Solution code:
import fractions

import numpy as np
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7

Z = np.lcm.reduce(np.array(A))
ans = sum(Z//a%mod for a in A)%mod
print(ans)

Submission status: Runtime Error

Solution code:
# Hello World program in Python
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)

Submission status: Runtime Error

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

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



n = int(input())

ans =1
res=0
arr = input().strip().split()


for i in range(n):
    arr[i] = int(arr[i])
    ans = lcm(ans,arr[i])
            
for i in range(n):
    res += ans // arr[i]
    res%=1000000007
            
print(res)

Submission status: Runtime Error

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

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


def cal_lcm(a, b):
  return int(a*b/gcd(a,b))


lcm = 1
ans = 0
for i in range(N):
  lcm_ = cal_lcm(lcm, a_list[i])
  ans = ans*int(lcm_/lcm) % MOD
  ans = (ans + int(lcm_/a_list[i])) % MOD
  lcm = lcm_

print(ans)

Submission status: Runtime Error

Solution code:

import fractions 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
for i, a in an:
    t = lcm_ // a
    ans += t 
    ans = ans - prime if ans >= prime else ans

print(ans)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import fractions

N=int(input())
a=list(map(int,input().split()))
ans=0
kbs=a[0]
kys=a[0]
ansans=0
for i in range(1, N):
    kys = fractions.gcd(kys, a[i])

    kbs*=a[i]

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

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

n = int(input())
aa = list(map(int,input().split()))
           
l = lcm(*aa)        
aal = [l//ai % MOD for ai in aa] 

print(sum(aal) % MOD)

Submission status: Runtime Error

Solution code:
import sys
def gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x
n=int(input())
if n==0:
  print(0)
  sys.exit()
else:
  c=list(map(int,input().split()))


v=[]


if len(c)==1:
  print(c[0] % (pow(10,9)+7))
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:
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 = ans * A[i] // fractions.gcd(ans, A[i])
for i in range(N):
  finans += (ans / A[i]) % (10 ** 9 + 7)
  finans = finans % (10 ** 9 + 7)
print(int(finans))

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

import numpy as np

p = 1e9+7
_ = input()
k = list(map(int, input().split(" ")))

l = lcm(k)

s = [l // t for t in k]
print(int(sum(s)%p))

Submission status: Runtime Error

Solution code:
import  fraction
from functools import reduce

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) // fraction.gcd(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:
MAX = 1000000

mod = 1000000007

prime = [0 for i in range(MAX)]

max_map = dict()

# function to return a^n

def power(a, n):

    if n == 0:
        return 1
    p = power(a, n // 2) % mod
    p = (p * p) % mod

    if n & 1:
        p = (p * a) % mod
    return p

# function to find the smallest prime
# factors of numbers upto MAX


def sieve():
    prime[0], prime[1] = 1, 1
    for i in range(2, MAX):
        if prime[i] == 0:
            for j in range(i * 2, MAX, i):
                if prime[j] == 0:
                    prime[j] = i
            prime[i] = i

# function to return the LCM modulo M


def lcmModuloM(arr, n):

    for i in range(n):
        num = arr[i]

        temp = dict()

        # temp stores mapping of prime factors
        # to its power for the current element
        while num > 1:

            # factor is the smallest prime
            # factor of num
            factor = prime[num]

            # Increase count of factor in temp
            if factor in temp.keys():
                temp[factor] += 1
            else:
                temp[factor] = 1

            # Reduce num by its prime factor
            num = num // factor

        for i in temp:
            # store the higest power of every prime
            # found till now in a new map max_map
            if i in max_map.keys():
                max_map[i] = max(max_map[i], temp[i])
            else:
                max_map[i] = temp[i]

    ans = 1

    for i in max_map:

        # LCM is product of primes to their
        # higest powers modulo M
        ans = (ans * power(i, max_map[i])) % mod
    return ans


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

# a^(-1) == a^(m-2)


def flt(a, mod):
    return rep_sqr(a, mod-2, mod)

# Driver code
sieve()

# python > pypy
MOD = 10**9 + 7

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

lcm_ = lcmModuloM(a, n)

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

Submission status: Runtime Error

Solution code:
from decimal import *

import fractions

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

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

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

print(int(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

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

lc = mp.lcm.reduce(a)

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

print(res)

Submission status: Runtime Error

Solution code:
import functools
import math

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

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

def lcm_list(nums):
        return functools.reduce(lcm, nums)

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

a_lcm = lcm_list(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:
import math
import numpy as np
import fractions

N=int(input())
a=list(map(int,input().split()))
ans=0
kbs=a[0]
kys=a[0]
ansans=0
for i in range(1, N):
    kys = fractions.gcd(kys, a[i])

    kbs*=a[i]

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

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)
    ans=int(l*((1/B).sum()))
    print(ans%mod)

Submission status: Runtime Error

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

factors = [0] * 2000
for a in A:
    d = 0
    while a % 2 == 0:
        d += 1
        a //= 2
    factors[2] = max(factors[2], d)
    for i in range(3, int(a ** 0.5) + 1, 2):
        d = 0
        while a % i == 0:
            d += 1
            a //= i
        factors[i] = max(factors[i], d)
        if a == 1:
            break
    if a > 1:
        factors[a] = max(factors[a], 1)

m = 1
for k, v in enumerate(factors):
    if v > 0:
        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:
N = int(input())
A = list(map(int,input().split()))
A.sort()
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:
from functools import reduce
from fractions import gcd
import numpy as np

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


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

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

temp = lcm_list(A)
l = [temp for _ in range(N)]
l = np.array(l)/np.array(A)
l = l%(10**9+7)
print(int(l.sum()%(10**9+7)))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import sys

sys.setrecursionlimit(100000000000)
n = input()
arr = np.array(list(map(int, input().split())))
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
lcm_v = lcm(arr)
div_arr = lcm_v / arr
print(int(div_arr.sum()) % (10**9 + 7))

Submission status: Runtime Error

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

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

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

a=A[0]
for b in A:
    a=lcm(a,b)
    #a = a /fractions.gcd(a, b)*b

count=0
for i in A:
    count+=a/i
    if count>(10**9)+7:
        count=count%((10**9)+7)
print(int(count)%((10**9)+7))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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:
mod = 1000000007
n = int(input())

num = [0]*n
for i in range(n):
    num[i] = int(input())
    
def HCF(a, b):
    if b == 0:
        return a
    else:
        return HCF(b, a%b)
    
lcm = num[0]

for i in range(n):
    lcm = (lcm * num[i])/(HCF(lcm, num[i]))

sum = 0

for i in range(n):
    sum = (sum%mod + (lcm//num[i])%mod)%mod

print(sum)

Submission status: Runtime Error

Solution code:
import sys
from math import gcd
n=int(input())
if n==0:
  print(0)
  sys.exit()
else:
  c=list(map(int,input().split()))


v=[]


if 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 math import gcd #直して
n = int(input())
a = list(map(int, input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fact = [0] * (1000001)
pri = []
for i in range(n):
    f = factorization(a[i])
    for fac, c in f:
        fact[fac] = max(fact[fac], c)

fact_list = []
for i in range(1000001):
    if fact[i] > 0:
        fact_list.append((i, fact[i]))




ans = 0
for i in range(n):
    m = modinv(a[i])
    for fac, c in fact_list:
        m *= pow(fac, c, mod)
        m %= mod

    ans += m
    ans %= mod

print(ans)

Submission status: Runtime Error

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

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

def cal_lcm(a, b):
  return int(a*b/gcd(a,b))


lcm = 1
sum_b = 0
ans = 0
for i in range(N):
  lcm_ = cal_lcm(lcm, a_list[i])
  ans = ans*int(lcm_/lcm) % MOD
  ans = (ans + int(lcm_/a_list[i])) % MOD
  lcm = lcm_

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

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

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

# print('input >>')
N = int(input())
A = list(map(int,(input().split())))

lcmn = lcm(*A)

ans = 0
for A_ in A:
    ans += (lcmn / A_) % mod

# print('-----output-----')
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)


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 % (1000000007)

print(int(result))

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd


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


MOD = 10**9 + 7

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

x = reduce(lcm, A)

ans = 0

for a in A:
    ans += x // a
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
def gcd(x,y):
  while(y): 
       x, y = y, x % y 
  return x 
n= int(input())
a = [int(u) for u in input().split()]
xx = a[0]

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

ANS=(sum%1000000007)
print(int(ANS))

Submission status: Runtime Error

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

d = defaultdict(int)

pf = []
for a in A:
    res = []
    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)
            res.append((i, cnt))
    if a != 1:
        d[a] = max(d[a], 1)
        res.append((i, cnt))
    pf.append(res)

ans = 0
for i, a in enumerate(A):
    tmpD = d.copy()
    for k, v in pf[i]:
        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:
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())
s = list(int(x) for x in input().split())
if(n == 1):
    print(s[0])
    exit()
l = lcm(s)
ans = 0
for i in range(n):
    ans += l / s[i]
    ans %= 1000000000 + 7
print(ans)

Submission status: Runtime Error

Solution code:


li = list(map(int,input().split()))
N = li[0]
aa = list(map(int,input().split()))

mod = 10 ** 9 + 7

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

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


r = 1
for a in aa:
  r = lcm(int(r), int(a))

ans = 0
for a in aa:
  ans += int(r / a)
  ans %= mod

print(ans)

Submission status: Runtime Error

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

_,p = [list(map(int, s.split())) for s in open(0)]
lcm = reduce(lcm_base, 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:
import math
from functools import reduce
import fractions as f
MOD = 1e9+7

def lcm_base(x, y):
    return (x * y) // f.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 = [int(x) for x in input().split()]

x = lcm_list(a)

ans = 0
for i in a:
    ans += x / i
    ans %= MOD
print(int(ans))

Submission status: Runtime Error

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

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

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

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

print(ans)

Submission status: Runtime Error

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

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

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

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

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(c/b[i])
print(int(num%(10**9+7)))

Submission status: Runtime Error

Solution code:
#import math
#from functools import reduce
from fractions import gcd
#from functools import lru_cache

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

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

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


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

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm/i
    
print(int(count%(10**9+7)))

Submission status: Runtime Error

Solution code:
import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c=c*A_//fractions.gcd(c,A_)
for A_ in A:
    a+=c/A_
print(int(a%w))

Submission status: Runtime Error

Solution code:
import math
n = int(input())
arr=[int (i) for i in input().split(" ")]

# def GCD(x, y): 
  
#   while(y): 
#       x, y = y, x % y 
  
#   return x 
   
def findlcm(arr, n) :
    ans = arr[0]
    for i in range(1,n):
        ans = (((arr[i] * ans))/(math.gcd(arr[i], ans))); 
    return ans


lcm = findlcm(arr, n)

sum = 0
MOD = 1000000007
for i in range(n):
    sum = (sum + (lcm/arr[i])%MOD)%MOD

print(int(sum))

Submission status: Runtime Error

Solution code:
import math

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

Submission status: Runtime Error

Solution code:
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):
    # print(gcd(a,b))
    return a * b/gcd(a, b)


mk = 1
for i in a:
    mk = lcm(mk, i)


k = 0
for i in a:
    k = (k +  mk / i) %MOD
print(int(k %MOD))

Submission status: Runtime Error

Solution code:
#E
n=int(input())
a=tuple(map(int,input().split()))
import fractions
lcm=a[0]
ans=1/a[0]
for i in range(1,n):
    lcm=lcm*a[i]//fractions.gcd(lcm,a[i])
    ans+=1/a[i]
num=10**9+7
print(int(ans*lcm)%num)

Submission status: Runtime Error

Solution code:
import functools
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm, numbers, 1)

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 fractions
print(1)
N = int(input())
a = list(map(int, input().split()))
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:
from fractions import gcd

def main():
	mod = 10 ** 9 + 7
    nok = 1
    n = int(input())
    a = [int(i) for i in input().split()]
    for i in a:
        nok = nok * i // gcd(nok, i)
    ans = 0
    for i in a:
        ans = (ans + nok // i) % mod
    print(ans)

main()

Submission status: Runtime Error

Solution code:
import fractions

#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))
    kobai = kobai * a // fractions.gcd(kobai, a)

sumN=0

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

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

print(sumN)

Submission status: Runtime Error

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

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)

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


pf = []
for a in A:
    res = []
    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)
            res.append((i, cnt))
    if a != 1:
        d[a] = max(d[a], 1)
        res.append((i, cnt))
    pf.append(res)

ans = 0
for i, a in enumerate(A):
    tmpD = d.copy()
    for k, v in pf[i]:
        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


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


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

Submission status: Runtime Error

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

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



n = int(input())

ans =1
res=0
arr = input().strip().split()


for i in range(n):
    arr[i] = int(arr[i])
    ans = lcm(ans,arr[i])
            
for i in range(n):
    res += ans / arr[i]
    res%=1000000007
            
print(int(res))

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

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