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

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

MOD=10**9+7

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

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

g=A[0]
for i in range(1, N):
    g = (g*A[i]*modinv(fractions.gcd(g, A[i]),MOD))
ans=0
for i in range(N):
  ans+=g*modinv(A[i],MOD)
  ans%=MOD
print(ans)

Submission status: Wrong Answer

Solution code:
from time import time
from fractions import gcd
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    s=lcm(s,t)
    if time()-start>.55:
        s=lcm(s,max(a))
        break
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys

sys.setrecursionlimit(1000000)
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: Wrong Answer

Solution code:
import collections
import sys

readline = sys.stdin.buffer.readline


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


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    C = 10**9 + 7

    d = collections.defaultdict(list)

    for a in A:
        B = factorization(a)
        for b in B:
            d[b[0]].append(b[1])
    e = 1
    for k, v in d.items():
        e += k**max(v)

    ans = 0
    for a in A:
        ans += (e // a)
        ans %= C
    print(ans)


main()

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A=list(map(int,input().split()))
    l=A[0]
    for x in A[1:]:
        l=l*x//gcd(l,x)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
import math
import fractions
from heapq import heappush, heappop


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

MOD = 10**9+7


def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0


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


def lcm(x, y):
    # return (x * y) // fractions.gcd(x, y)
    return (x * y) * modinv(fractions.gcd(x, y), MOD)


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

lm = 1


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

lm %= MOD


# print(lm)
ans = 0
for i in range(N):
    m = modinv(A[i], MOD)
    ans += lm * m
    ans %= MOD

print(ans)

Submission status: Wrong Answer

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

if N == 1:
    res = A[0]
else:
    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: Wrong Answer

Solution code:
import sys
import fractions

input = sys.stdin.readline

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


if N==1:
    print(1)
    exit()

index = A[0]

for a in A[1:]:
    index = index * a // fractions.gcd(index, a)

MOD = 10**9 + 7

ans = 0
print(index)

for a in A:
    ans += (index//a) % MOD

Submission status: Wrong Answer

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

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


def pow_mod(x,n):
    if n==0:
        return 1
    
    K = 1
    while n>1:
        if n%2 != 0:
            K *= x
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K*x

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

if N==1:
    print(1)
    exit()

Gcd = gcd(A[0],A[1])
ans = (A[0]//Gcd+A[1]//Gcd)%mod
temp = A[0]//Gcd

for i in range(1,N-1):
    #Gcd = lcm(A[i],A[i+1])
    Gcd = gcd(A[i],A[i+1])
    #temp2 = Gcd//A[i]
    temp2 = A[i+1]//Gcd
    #Gcd2 = lcm(temp,temp2)
    Gcd2 = gcd(temp,temp2)

    #a = Gcd2//temp
    a = temp2//Gcd2
    #b = Gcd2//temp2
    b = temp//Gcd2

    temp = Gcd//A[i+1]*b

    a %= mod
    b %= mod
    ans *= a
    ans %= mod


    Gcd %= mod #注意
    c = A[i]
    c %= mod
    d = c*pow_mod(Gcd,mod-2)
    #d = Gcd//c
    d %= mod


    e = b*d%mod
    ans += e
    #ans += Gcd//A[i+1]*b
    ans %= mod


print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

for ai in A:
    pro=lcm(pro,ai)

# pro2=1
# for ai in A:
#     pro2=(pro2*ai)%mod
#     pro=gcd(pro,ai)
# for ai in A:
#     count+=pro//ai
#     count%=mod
# print(count)

Submission status: Wrong Answer

Solution code:
#  --*-coding:utf-8-*--

MOD = 10**9 + 7

def getPrimes(n):
    if (n < 2):
        return []

    flags = [False]*(n+1)
    primes = [2]

    for p in range(3, n+1, 2):
        if not flags[p]:
            primes.append(p)
            for k in range(p**2, n+1, p):
                flags[k] = True

    return primes


def modPow(a, b, mod):
    x = 1
    
    while b > 0:
        if b & 1:
            x = (x*a)%mod

        a = (a**2)%mod
        b //= 2

    return x


def getModInv(a, b):
    return 1 if (a == 1) else int((1-b*getModInv(b%a, a))/a%b)


def getFactors(x):
    factors = {}
    for p in P:
        n = 0
        while x%p == 0:
            x //= p
            n += 1

        if n > 0:
            factors[p] = n

    return factors


P = getPrimes(1000)

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

maxFacts = {}

for a in A:
    facts = getFactors(a)
    for p in facts:
        if not p in maxFacts or maxFacts[p] < facts[p]:
            maxFacts[p] = facts[p]
                
lcd = 1
for p in maxFacts:
    lcd = lcd * modPow(p, maxFacts[p], MOD)%MOD


s = 0
for a in A:
    s += lcd*getModInv(a, MOD)%MOD

print(s%MOD)

Submission status: Wrong Answer

Solution code:
from time import time
from fractions import gcd
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    s=lcm(s,t)
    if time()-start>.6:
        s=max(a)
        break
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

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

import fractions
print(fractions.gcd(6,10))
def lcm(a,b):
    return a*b//fractions.gcd(a,b)

def power(a,p):
    T=[a]
    while 2**(len(T))<p:
        T.append(T[-1]**2%p)
    b=bin(p-2)
    ans=1
    for i in range(len(b)-2):
        if int(b[-i-1])==1:
            ans=ans*T[i]%p
    return ans   

l=A[0]
for i in range(n-1):
    l=lcm(l,A[i+1])
s=0
for i in range(n):
    s+=l*power(A[i],mod)%mod
    s%=mod
print(s)

Submission status: Wrong Answer

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])) % res) * 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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
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: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), np.uint64)
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD


B = np.array([LCM] * N, np.uint64)
B = B//A

ans = 0
for i in range(N):
	t = B[i] % mod
	ans += t
	ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
INL = LI()
gcdall=INL[0]
lcmall=INL[0]
for i in INL:
    gcdall = gcd(gcdall, i)%DVSR
    lcmall = (((lcmall*i)%DVSR)*INV(gcd(lcmall, i)))%DVSR
# print(lcmall)

res = 0
for i in INL:
    # print(((lcmall*INV(i))%DVSR * i)%DVSR)
    res += (lcmall*INV(i))%DVSR
print(res%DVSR)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np
MOD = 10**9+7
 
def lcm_n(l):
    rtn = l[0]
    for i in range(1,N):
        rtn = rtn * l[i] // fractions.gcd(rtn,l[i])
    return rtn
  
N = int(input())
A = np.array(list(map(int,input().split())),dtype = np.int64)
lcm = lcm_n(A)
ans = 0
A = (lcm // A) % MOD
 
print(sum(A) % MOD)

Submission status: Wrong Answer

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


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

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

mod = 10**9+7
lcm = 1
B = [0]*N

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

ans = 0


# for i in range(N):
#     ans += (lcm * inv_t[A[i]]) % mod
#     ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict
import bisect
from fractions import Fraction
 
 
N = int(input())
A=list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += Fraction(1, A[i])
    
print(ans.numerator%(10**9+7))

Submission status: Wrong Answer

Solution code:
def main():
    import fractions
    import sys
    input = sys.stdin.readline
    N = int(input())
    a = tuple(map(int,input().split()))
    MOD = 10**9+7
    g1 = 1
    for i,t in enumerate(a[:N//2]):
        g1 = divmod(g1*t,fractions.gcd(g1,t))[0]

    g2 = 1
    for i,t in enumerate(a[N//2:]):
        g2 = divmod(g2*t,fractions.gcd(g2,t))[0]
    res = 0
    r1 = g2%MOD
    for t in a[:N//2]:
        res += r1*divmod(g1,t)[0]%MOD
    r2 =g1%MOD
    for t in a[N//2:]:
        res += r2*divmod(g2,t)[0]%MOD
    print(res%MOD)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def lcd(a, b):
    return (a*b)//gcd(a, b)
def solve(N, A):
    MOD = 1000000007
    if N == 1:
        return 1

    A0 = A[0]
    m = 0
    B0 = 1
    for i in range(1,N):
        g = gcd(A0, A[i])
        if g == 1:
            B0 *= A[i]
    AB = A0 * B0

    answer = B0 % MOD
    p = 1
    for i in range(1, N):
        a = A[i]
        q, r = divmod(AB, a)
        if r == 0:
            b = q
            #B[i] = q
            answer = (answer + b) % MOD
        else:
            l = lcd(AB, A[i])
            q = l // AB
            p *= q
            AB *= q
            b = l // a
            #B[i] = b
            #print("*%d"%p)
            #for j in range(i): B[j] *= p
            answer = (((answer*p)%MOD) + b) % MOD
        #print(B[:i+1], answer)
    #print(B)
    print(answer)

solve(N, A)

Submission status: Wrong Answer

Solution code:
n=int(input())
list1=list(map(int,input().split()))
import fractions
ans=list1[0]
for i in range(1, n):
    ans = ans * list1[i] // fractions.gcd(ans, list1[i])
sum1=0
for i in list1:
    sum1+=ans//i
print(sum1//(10**9+7))

Submission status: Wrong Answer

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

p = 1
for a in al:
    p *= a

ans = 0
for a in al:
    ans += p // a

print(ans)

Submission status: Wrong Answer

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

if n == 1:
    print(a[0])
    exit()

g = fractions.gcd(a[0], a[1])
f = a[0]*a[1]//g
ans = a[0]//g+a[1]//g

for i in range(2, n):
    # print(ans, g, f)
    h = fractions.gcd(f, a[i])
    g = a[i] // h
    f = f*a[i]// h
    ans *= g
    ans += f // a[i]
    ans %= mod
print(ans%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), np.int64)
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD


B = np.array([LCM] * N, np.int64)
B = B//A

ans = 0
for i in range(N):
	t = B[i] % mod
	ans += t
	ans %= mod

print(ans)

Submission status: Wrong Answer

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])
#for j in range(0, n):
#  b = ans // a[j]
#  ans_ans = add(ans_ans,b)
  
#print(ans_ans)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().split()[0])
a = [int(i) for i in input().split()]
print(N, a)

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 = a[0]
for i in range(1, N):
    l = lcm(l, a[i])

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
from fractions import*
from functools import*
from operator import*
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
if n<10**4:t=reduce(lcm,a)
else:t=reduce(mul,a)
c=0
for i in a:
    c+=t//i
    c%=M
print(c)

Submission status: Wrong Answer

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

koubai = max(A)
B = list(map(lambda x:(koubai/x)%(10**9+7), A))

for b in B:
  res += b
  res = res % (10**9+7)

print(int(res))

Submission status: Wrong Answer

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

if n == 1:
    print(a[0])
    exit()

h = fractions.gcd(a[0], a[1])
g = h % mod
f = a[0]*a[1]//g
ans = a[0]//g+a[1]//g

for i in range(2, n):
    # print(ans, g, f)
    h = fractions.gcd(f, a[i])
    g = a[i] // h % mod
    f = f*a[i]// h
    ans *= g
    ans += f // a[i]
    ans %= mod
print(ans%mod)

Submission status: Wrong Answer

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)

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

n=input()
hoge=list(map(int,input().split()))
#hoge=[i for i in range(1,10**4)]
tmp=lcm_list(hoge)
ans=0
mod=10**9+7
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), np.int64)
mod = 10**9+7
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b, a%b)
LCM = A[0]
for i in range(1, N):
	GCD = gcd(LCM, A[i])
	LCM *= A[i]
	LCM //= GCD

B = np.array([LCM] * N, np.int64)
B = B//A
C = np.sum(B) % mod
print(C)
#ans = 0
#for i in range(N):
#	ans += LCM//A[i]
#	ans %= mod

#print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0

for i in range(n):
    ans += Fraction(1, a[i])
print(ans.numerator % MOD)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math




N = int(input())


import fractions
a = list(map(int, input().split()))
koubai = a[0]
for i in range(1, N):
    koubai = koubai * a[i] // fractions.gcd(koubai, a[i])
    if(koubai >=1000000000000007):
        break

ans = int(0)
for i in range(N):
    ans += koubai // a[i]
    
ans %= 1000000007

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**10000:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
lcm=A[0]

chk=True

for i in range(1,n):
  if lcm%A[i]!=0:
    lcm=lcm*A[i]//gcd(lcm,A[i])
  if lcm>10**100:
    chk=False
    break

if chk:
  ans=0
  for i in range(n):
    ans=(ans+lcm//A[i])%mod
  print(ans)
else:
  ans=0
  mult=1
  for a in A:
    mult=(mult*a)%mod
  for a in A:
    ans=(ans+mult*pow(a,mod-2,mod))%mod
  print(ans)

Submission status: Wrong Answer

Solution code:
mod = 1000000007

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

def lcm(a, b):
    m = a // gcd(a, b)
    m *= b
    # m %= mod
    return m

def modinv(a):
    b = mod
    u = 1
    v = 0
    while (b):
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u

    u %= mod
    if (u < 0):
        u += mod
    return u

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

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    isPrime = primes(1000000)
    # print(p)

    
    lc = 1
    for i in range(N):
        if (isPrime[A[i]]):
            lc = lc * A[i]
        else:
            lc = lcm(lc, A[i])
        # lc %= mod

    ans = 0
    for i in range(N):
        # r = lc * modinv(A[i])
        r = lc // A[i]
        ans += r
        ans %= mod

    print(ans)

Submission status: Wrong Answer

Solution code:
# from math import gcd
mod = 10**9 + 7

n = int(input())
arr = [int(j) for j in input().split()]

# prod = 1
# l = 1
# for x in arr:
# 	g = gcd(l, x)
# 	prod = l*x
# 	l = prod//g

# su = 0
# for x in arr:
# 	su += (l//x)
# print(su%mod)

Submission status: Wrong Answer

Solution code:
mod = 1000000007

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

def lcm(a, b):
    m = a // gcd(a, b)
    m *= b
    # m %= mod
    return m

def modinv(a):
    b = mod
    u = 1
    v = 0
    while (b):
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u

    u %= mod
    if (u < 0):
        u += mod
    return u

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

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))

    isPrime = primes(1000000)
    # print(p)

    
    lc = 1
    for i in range(N):
        if (isPrime[A[i]]):
            lc = lc + A[i]
        else:
            lc = lcm(lc, A[i])

    ans = 0
    for i in range(N):
        # r = lc * modinv(A[i])
        r = lc // A[i]
        ans += r
        ans %= mod

    print(ans)

Submission status: Wrong Answer

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

n=int(input())
a=list(map(int,input().split()))
a=list(set(a))
a.sort(reverse=1)
ans=0
m=int(10**9+7)
g=1
l=1
for x in a:
  if l%x!=0:
    g=gcd(l,x)
    l=l*x//g

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

print(ans%m)

Submission status: Wrong Answer

Solution code:
from time import*
from fractions import*
start=time()
M=10**9+7
lcm=lambda x,y:x//gcd(x,y)*y
n,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
s=a[0]
for t in a[1:]:
    if time()-start>.5:
        s*=t
    else:
        s=lcm(s,t)
c=0
for i in a:
    c+=s//i
    c%=M
print(c)

Submission status: Wrong Answer

Solution code:
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m

if __name__ == "__main__":
    N = int(input())
    A = list(map(int,input().split()))
    mod = 10**9+7
    a = A[0]
    for i in range(1,N):
        a = a//xgcd(a,A[i])[0] * A[i] % mod
    b = 0
    for i in range(N):
        B = modinv(A[i],mod)
        c = a*B % mod
        b = (b+c)% mod
    print(b)

Submission status: Wrong Answer

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

Solution code:
import fractions

M=10**9+7
ans=0
n=int(input())
A=list(map(int,input().split()))
x = A[0]
for i in A:
  x = (x*i) // fractions.gcd(x,i)
for i in A:
  ans += (x//i) % M
print(ans)

Submission status: Wrong Answer

Solution code:
#import math
#gcd = math.gcd
from fractions import gcd



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

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

ans = 0
MOD = 10**9+7

cur = 1
for a in A:
    cur =  lcm(cur,a)
    
for a in A:
    ans += cur//a
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import fractions
from functools import reduce

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


from math import sqrt
M = 10**6
p = [1]*(M+1)
p[0] = p[1] = 0
for x in range(2, int(sqrt(M))+1):
    if p[x]:
        for y in range(x*x, M+1, x):
            p[y] = 0

n = int(input())
al = list(map(int, input().split()))
bl = list(set(al))
lc = 1
for a in al:
    if p[a] == 0:
        lc = lcm(lc, a)
    else:
        lc *= a
ans = 0
for a in al:
    ans += lc // a
    ans %= 10**9 + 7

print(ans)

Submission status: Wrong Answer

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

if n == 1:
    print(a[0])
    exit()

g = fractions.gcd(a[0], a[1])
f = a[0]*a[1]//g
ans = a[0]//g+a[1]//g
for i in range(2, n):
    # print(ans, g, f)
    h = fractions.gcd(f, a[i])
    g = a[i] // h % mod
    f = f*a[i]// h
    ans *= g
    ans += f // a[i]
    ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

Submission status: Wrong Answer

Solution code:

MOD = 10**9+7

def extgcd(a,b): #互いに素なa,bについて、a*x+b*y=1の一つの解
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,mod): # (x/a)%MODをしたい時は x%MOD * mod_inv(a,MOD)%MOD
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod


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

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

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

lcm_ = a[0]
ans = 1
for i in range(1,n):
    a_i = a[i]%MOD
    if lcm_ % a[i] != 0:
        lcm_new = lcm(lcm_, a[i])
        ans = ans*(lcm_new%MOD *mod_inv(lcm_,MOD)%MOD)
        lcm_ = lcm_new%MOD
    ans += lcm_%MOD * mod_inv(a_i, MOD)%MOD

print(ans%MOD)

Submission status: Wrong Answer

Solution code:
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
#sys.setrecursionlimit(314159265)

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


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

def lcm_list(nums):
    if len(nums) == 0:
        return None
    if len(nums) == 1:
        return nums[0]
    if len(nums) == 2:
        lcm(nums[0], nums[1])
    else: # > 2
        a = lcm(nums[0], nums[1])
        for i in range(2, len(nums)):
            A = lcm(a, nums[i])
            a = A
        return a




def sol(S):
    mod = 10**9 + 7
    x = lcm_list(S)
    print(x)
    T = [ x//s for s in S]
    return sum(T) % mod







do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    # n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    S = parsed_lines[0][0]
    return S


if not do_submit:
    S = input_parse("""
    1905
    """)
    print(sol(S))

    S = input_parse("""
    0112
    """)
    print(sol(S))

    S = input_parse("""
    1700
    """)
    print(sol(S))

    S = input_parse("""
    0000
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    n = int(input())
    S = list(map(int, input().split()))
    #S = input()
    print(sol(S))

    # S = input().strip()
    # print(sol(S))
    # print(lcm(2, 3))
    # print(lcm_list([2, 3, 4]))
    # print(lcm_list([27, 9, 3]))

Submission status: Wrong Answer

Solution code:
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i,b in enumerate(a):
        if i==0: pass
        x = (x * b) // gcd(x, b)
    return x

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
gcd=lcm(a)
res=0
for i,b in enumerate(a):
    if i==0:continue
    res+=gcd//b
print(res%mod)

Submission status: Wrong Answer

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

def lcd(a, b):
    return (a*b)//gcd(a, b)
def solve(N, A):
    MOD = 1000000007
    if N == 1:
        return 1

    A0 = A[0]
    G = [1] * N
    B = [1] * N
    m = 0
    for i in range(1,N):
        g = lcd(A0, A[i])
        m = max(m, g)
    B0 = m // A0
    AB = A0 * B0

    answer = B0 % MOD
    p = 1
    for i in range(1, N):
        #print(i)
        a = A[i]
        q, r = divmod(AB, a)
        #print("i:%d,"%i,"r=%d"%r)
        if r == 0:
            b = q
            #B[i] = q
            answer = (answer + b) % MOD
        else:
            l = lcd(AB, A[i])
            q = l // AB
            p *= q
            p %= MOD
            AB *= q
            b = l // a
            #B[i] = b
            #print("*%d"%p)
            #for j in range(i): B[j] *= p
            answer = (((answer*p)%MOD) + b) % MOD
        #print(B[:i+1], answer)
    #print(B)
    print(answer)

solve(N, A)