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

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

mod = 10**9 + 7

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)

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

x = lcm_list(a)
x %= mod
# print(x)

ans = 0
for i in range(n):
    ans += int(x/a[i])%mod

print(int(ans)%mod)

Submission status: Wrong Answer

Solution code:
import sys
 
input = sys.stdin.readline
 
ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]
 
import sys
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)
 
def lcm_list(numbers):
    ans = 1
    for num in numbers:
        ans = ans * num // fractions.gcd(ans,num)
    return ans
 
def LI():
  return [int(s) for s in input().split()]
 
input = sys.stdin.readline
ri = lambda: int(input())
ril = lambda: list(map(int, input().split()))
 
N = ri()
A_s = np.array(ril())
mod = 10**9 + 7
 
#l = lcm_list(A_s)
l = 1
for num in A_s:
    l = l * num // fractions.gcd(l,num)

print(sum(l//A_s) % mod)

Submission status: Wrong Answer

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

#arr：最小公倍数の対象とする配列
MOD = 10**9 + 7
def lcm(arr):
    primes = {}
    for val in arr:
        p = 2
        while p * p <= val:
            if val % p == 0:
                cnt = 0
                while val % p == 0:
                    cnt += 1
                    val //= p
                if p not in primes:
                    primes[p] = cnt
                else:
                    primes[p] = max(cnt, primes[p])
            p += 1
     
        if val != 1:
            if val not in primes:
                primes[val] = 1
    lcma = 1
    for p in primes:
        lcma = lcma * pow(p, primes[p], MOD) % MOD
    return lcma

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

print(ans%MOD)

Submission status: Wrong Answer

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

#arr：最小公倍数の対象とする配列
MOD = 10**9 + 7
def lcm(arr):
    primes = {}
    for val in arr:
        p = 2
        while p * p <= val:
            if val % p == 0:
                cnt = 0
                while val % p == 0:
                    cnt += 1
                    val //= p
                if p not in primes:
                    primes[p] = cnt
                else:
                    primes[p] = max(cnt, primes[p])
            p += 1
     
        if val != 1:
            if val not in primes:
                primes[val] = 1
    lcma = 1
    for p in primes:
        lcma = lcma * pow(p, primes[p], MOD) % MOD
    return lcma

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import reduce
from fractions import gcd
import numpy as np

MOD = 10**9+7

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

def main():
    #N = int(input())
    #a = [int(i) for i in input().split()]
    #A = np.array(a)
    N = int(readline())
    A = np.array(read().split(),np.int64)

    lcm = reduce(lcm_base, A, 1)
    #lcm = np.lcm.reduce(A)
    B = lcm // A

    print(np.sum(B) % MOD)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,m = [int(i) for i in readline().split()]
#d = [int(i) for i in readline().split()]
MOD = 10**9+7

n = int(input())
a = [int(i) for i in readline().split()]

from fractions import gcd

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

b = a[:]
for i in range(11):
    d = 1<<i
    for k in range(d,n,2*d):
        a[k-d] = lcm(a[k],a[k-d])
m = a[0]

ans = 0
for i in b:
    ans += m//i

print(ans%MOD)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    return gcd(b,b%a) if b else a
def lcm(a,b):
    return a*b//gcd(a,b)
k=1
for i in a:
    k = lcm(k,i)
ans=0
for i in a:
    ans += k//i
    ans %= 1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import numpy as np
N = int(input())
A_lis = np.array(list(map(int, input().split())))
MOD = 10 ** 9 + 7

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

B_lis = A_lis / ans
B_sum = sum(B_lis)

print(B_sum % MOD)

Submission status: Wrong Answer

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

import fractions

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

output = 0
for i in range(N):
    output += X*pow(A[i],10**9+5,10**9+7)%(10**9+7)
    output = output % (10**9+7)
print(int(output))

Submission status: Wrong Answer

Solution code:
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)


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

n = ip()
a  = iprow()

lowest = a[0]
shortend = list(set(a))
for i in range(1,len(shortend)):
    lowest = lcm(lowest,shortend[i])
bottom = []
for i in range(n):
    bottom.append((lowest//a[i])%rem)
print(sum(bottom)%rem)

Submission status: Wrong Answer

Solution code:
from functools import reduce

MOD = 10**9 + 7

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return (x2, y2, n)

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm_mod(a, b, mod): return (((a * b) % mod) * modular_inverse(gcd(a, b), mod)) % mod
def lcm_mod_list(A, mod): return reduce(lambda x, y: lcm_mod(x, y, mod), A)

N = int(input())
*A, = map(int, input().split())
L = lcm_mod_list(A, MOD)
ans = 0
for a in A:
    ans = (ans + L // a) % MOD
print(ans)

Submission status: Wrong Answer

Solution code:
# 最小公倍数
from fractions import gcd
from functools import reduce
def lcm (x, y):
    return (x * y) // gcd(x, y)

# 最小公倍数(リスト)
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

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

lcm_A = lcm_list(A) % mod

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


print(ans % mod)

Submission status: Wrong Answer

Solution code:
from functools import reduce

def extended_euclid(a, b):
    x1, y1, m = 1, 0, a
    x2, y2, n = 0, 1, b
    while m % n != 0:
        q, r = divmod(m, n)
        x1, y1, m, x2, y2, n = x2, y2, n, x1 - q * x2, y1 - q * y2, r
    return (x2, y2, n)

def modular_inverse(a, mod):
    x, _, g = extended_euclid(a, mod)
    if g != 1:
        return None # Modular inverse of a does not exist
    else:
        return x % mod
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm_mod(a, b, mod): return a * b * modular_inverse(gcd(a, b), mod)
def lcm_mod_list(A, mod): return reduce(lambda x, y: lcm_mod(x, y, mod), A)

MOD = 10**9 + 7

N = int(input())
*A, = map(int, input().split())
L = lcm_mod_list(A, MOD)
ans = 0
for a in A:
    ans = (ans + L // a) % MOD
print(ans)

Submission status: Wrong Answer

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

num = a[0]
for i in range(1, n):
	num = (num * a[i]) // fractions.gcd(num, a[i])
 
ans = 0
for i in range(n):
	ans += (num//a[i]) % 1000000007

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import collections
def main():

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

    def primes(n):
        b = [True] * (n//2)
        for i in range(3, int(n**0.5)+1, 2):
            if b[i//2]:
                b[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)

        return [2] + [2*i + 1 for i in range(1, n//2) if b]

    def isprime(n):
        if n == 1: return False
        for i in range(2, int(math.sqrt(n))+1):
            if n % i == 0:
                return False
        return True

    A = sorted(list(set(A)))
    N = len(A)

    ps = primes(int(math.sqrt(max(A))))

    d = dict()
    di = collections.defaultdict(dict)
    for i in range(N):
        if isprime(A[i]):
            if A[i] not in d:
                d[A[i]] = 1
            di[i][A[i]] = 1
        else:
            v = A[i]
            for p in ps:
                if p > v: break
                cnt = 0
                while v > 1 and v % p == 0:
                    cnt += 1
                    v //= p
                if p in d:
                    d[p] = max(d[p], cnt)
                else:
                    d[p] = cnt
                di[i][p] = cnt
            if v > 1:
                di[i][v] = 1
                if v not in d:
                    d[v] = 1

    ans = 0
    for i in range(N):
        b = 1
        for p in d:
            if p in di[i]:
                b *= pow(p, d[p]-di[i][p])
            else:
                b *= pow(p, d[p])
            b %= mod
        ans += b
        ans %= mod

    return ans

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
# from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
# from heapq import heappop, heappush, heappushpop
# from collections import Counter,defaultdict,deque
# from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
# from bisect import bisect_left,bisect_right
# from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
#mint
class ModInt:
    def __init__(self, x):
        self.x = x % mod
    
    def __str__(self):
        return str(self.x)
    
    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x)
        else:
            return ModInt(self.x + other)

    __radd__ = __add__
        
    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x)
        else:
            return ModInt(self.x - other)

    def __rsub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x)
        else:
            return ModInt(other - self.x)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x)
        else:
            return ModInt(self.x * other)

    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, mod-2,mod))
        else:
            return ModInt(self.x * pow(other, mod - 2, mod))
            
    def __rtruediv(self, other):
        if isinstance(other, self):
            return ModInt(other * pow(self.x, mod - 2, mod))
        else:
            return ModInt(other.x * pow(self.x, mod - 2, mod))
            

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, mod))
        else:
            return ModInt(pow(self.x, other, mod))
            

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, mod))
        else:
            return ModInt(pow(other, self.x, mod))

def main():
    N=I()
    A=LI()
    l = 1
    for a in A:
        l *= a//gcd(l,a)
    ans = 0
    l%=mod
    for a in A:
        ans += l//a
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

MOD=10**9+7

primes=[]
is_prime=[True]*(5*(10**5))
for i in range(2,5*(10**5)):
    if not is_prime[i]: continue
    primes.append(i)
    for j in range(2*i,5*(10**5),i):
        is_prime[j]=False

F=[[0 for _ in range(len(primes))] for __ in range(N)]
LCM=[0 for _ in range(len(primes))]
for i in range(N):
    n=A[i]
    for j,p in enumerate(primes):
        while n%p==0:
            F[i][j]+=1
            LCM[j]=max(LCM[j],F[i][j])
            n//=p

ans=0
for i in range(N):
    tmp=1
    for j,p in enumerate(primes):
        tmp=tmp*pow(p,LCM[j]-F[i][j],MOD)%MOD
    ans=(ans+tmp)%MOD

print(ans)

Submission status: Wrong Answer

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

def GCD(x,y):
    if y==0:
        return x
    return GCD(y,x%y)
lcm = 1
for i in A:
    lcm = lcm*i*pow(GCD(lcm,i),MOD-2,MOD)
ans = 0
lcm %= MOD
for i in A:
    ans += lcm*pow(i,MOD-2,MOD)
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:

MOD = 1000000007

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

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

n = int(input())
a = list(map(int,input().split()))
all_lcm = 1
for i in range(n):
    all_lcm = lcm(all_lcm, a[i])
ans = 0
for i in range(n):
    ans += all_lcm//a[i]
print(ans%MOD)

Submission status: Wrong Answer

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

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])
    #lcm = lcm * a[i] // math.gcd(lcm, a[i])\
lcm %= MOD
for i in range(n):
    ans += lcm * pow(a[i] , MOD-2, MOD)
#     ans %= MOD
print(ans)

Submission status: Wrong Answer

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()))
    mod=10**9 + 7
    tmp = lcm(*a) % mod
    
    m=0
    ans=0
    for i in range(len(a)):
        v=a[i]
        m=tmp//v
        ans+=m%mod
    ans = ans % mod
    print(ans)

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)


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:

MOD = 1000000007

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)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    all_lcm = a[0]
    for i in range(n):
        all_lcm = lcm(all_lcm, a[i])
    ans = 0
    for i in range(n):
        ans += all_lcm//a[i]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import collections
def main():

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

    def primes(n):
        b = [True] * (n//2)
        for i in range(3, int(n**0.5)+1, 2):
            if b[i//2]:
                b[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)

        return [2] + [2*i + 1 for i in range(1, n//2) if b]

    def isprime(n):
        if n == 1: return False
        for i in range(2, int(math.sqrt(n))+1):
            if n % i == 0:
                return False
        return True

    ps = primes(int(math.sqrt(max(A))) + 1)

    d = dict()
    di = collections.defaultdict(dict)
    for i in range(N):
        if isprime(A[i]):
            if A[i] not in d:
                d[A[i]] = 1
            di[i][A[i]] = 1
        else:
            v = A[i]
            for p in ps:
                if p > int(math.sqrt(A[i])):
                    break
                cnt = 0
                while v > 1 and v % p == 0:
                    cnt += 1
                    v //= p
                if p in d:
                    d[p] = max(d[p], cnt)
                else:
                    d[p] = cnt
                di[i][p] = cnt
            if v > 1:
                di[i][v] = 1
                if v not in d:
                    d[v] = 1

    ans = 0
    for i in range(N):
        b = 1
        for p in d:
            if p in di[i]:
                b *= pow(p, d[p]-di[i][p])
            else:
                b *= pow(p, d[p])
            b %= mod
        ans += b
        ans %= mod

    return ans

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import fractions
import sys
sys.setrecursionlimit(50000)

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(fractions.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: Wrong Answer

Solution code:
import math
import fractions
n = int(input())


l = input().split()
for i in range(n):
    l[i] = int(l[i])
lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]%1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import math
n = input()
li = list(map(int, input().split()))
a = 1
for i in li:
    a = a * i / fractions.gcd(a, i)
ans = 0
mod = 1000000007
for i in li:
    ans += (a / i) % mod
print(math.floor(ans))

Submission status: Wrong Answer

Solution code:
import math
import fractions
n = int(input())


l = input().split()
for i in range(n):
    l[i] = int(l[i])
lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
ans = 0
for i in range(n):
    ans+=lc//l[i]
print(ans)

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import fractions
n = int(input())


l = input().split()
for i in range(n):
    l[i] = int(l[i])
lc = 1

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


for i in range(n):
    lc = lcm(lc,l[i])
for i in range(n):
    print(lc//l[i])
    print(" ")

Submission status: Wrong Answer

Solution code:
import math
import fractions
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 union_lcm(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=num*lists[i]//fractions.gcd(num,lists[i])
        return num


#最大公約数
def union_gcd(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=fractions.gcd(num,lists[i])
        return num
mod=10**9+7   
n=int(input())
lists=list(map(int,input().split()))
a=union_gcd(lists)
c=0
a=a%mod
for i in range(n):
    c+=a*modinv(lists[i],mod)
    c=c%mod
print(c)

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import reduce
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools
import math

def acinput():
    return list(map(int, input().split(" ")))


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

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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Wrong Answer

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

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

print(ans%MOD)

Submission status: Wrong Answer

Solution code:
import numpy as np 

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

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

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

lcm_a = 1

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

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

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

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import reduce
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools
import math

def acinput():
    return list(map(int, input().split(" ")))


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

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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Wrong Answer

Solution code:
import numpy as np 

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

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

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

lcm_a = 1

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

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

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
l = 1
for i in a:
    l = i * l // (gcd(i, l))

res = []
y = 2
while y*y <= l:
    while l % y == 0:
        res.append(y)
        l //= y
    y += 1
if l > 1:
    res.append(l)

cnt = 0
for i in a:
    cnt += 1 / i
for i in res:
    cnt *= i
    cnt %= mod
print(round(cnt))

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import reduce
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools

def acinput():
    return list(map(int, input().split(" ")))


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


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


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


def lcm_list2(numbers):
    res=numbers[0]
    for n in numbers:
        res=lcm_base(n,res)
    return res

N=int(input())
a=np.array(acinput())
s=np.array(lcm_list2(a))
v=s/a
print(int(np.sum(v))%(10**9+7))

#print(v)
#print(s)

Submission status: Wrong Answer

Solution code:

import fractions as fr
import functools as ft
#import math as fr


prime = 10**9+7

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

an.sort()


lcm_ = 1
for a in an :
    lcm_ = a*lcm_ // fr.gcd(a, lcm_)
#    print(lcm_)
    
#ans = 0
#for a in an:
#    ans += lcm_ // a
#    ans = ans % prime if ans >= prime else ans

ans = ft.reduce(lambda x,y: (x + lcm_//y)%(prime*10), an ,0 )

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import collections
def main():

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

    def primes(n):
        b = [True] * (n//2)
        for i in range(3, int(n**0.5)+1, 2):
            if b[i//2]:
                b[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)

        return [2] + [2*i + 1 for i in range(1, n//2) if b]

    def isprime(n):
        if n == 1: return False
        for i in range(2, int(math.sqrt(n))+1):
            if n % i == 0:
                return False
        return True

    ps = primes(int(math.sqrt(max(A))))

    d = dict()
    di = collections.defaultdict(dict)
    for i in range(N):
        if isprime(A[i]):
            if A[i] in d:
                d[A[i]] = max(d[A[i]], 1)
            else:
                d[A[i]] = 1
            di[i][A[i]] = 1
        else:
            v = A[i]
            for p in ps:
                cnt = 0
                if p > math.sqrt(A[i]):
                    break
                while v > 0 and v % p == 0:
                    cnt += 1
                    v //= p
                if p in d:
                    d[p] = max(d[p], cnt)
                else:
                    d[p] = cnt
                di[i][p] = cnt

    ans = 0
    for i in range(N):
        b = 1
        for p in d:
            if p in di[i]:
                b *= pow(p, d[p]-di[i][p])
                b %= mod
            else:
                b *= pow(p, d[p])
                b %= mod
        ans += b
        ans %= mod

    return ans

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import math
import collections
def main():

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

    def primes(n):
        b = [True] * (n//2)
        for i in range(3, int(n**0.5)+1, 2):
            if b[i//2]:
                b[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)

        return [2] + [2*i + 1 for i in range(1, n//2) if b]

    def isprime(n):
        if n == 1: return False
        for i in range(2, int(math.sqrt(n))+1):
            if n % i == 0:
                return False
        return True

    ps = primes(max(A))

    d = dict()
    di = collections.defaultdict(dict)
    for i in range(N):
        if isprime(A[i]):
            if A[i] in d:
                d[A[i]] = max(d[A[i]], 1)
            else:
                d[A[i]] = 1
            di[i][A[i]] = 1
        else:
            v = A[i]
            for p in ps:
                cnt = 0
                if p > math.sqrt(A[i]):
                    break
                while v > 0 and v % p == 0:
                    cnt += 1
                    v //= p
                if p in d:
                    d[p] = max(d[p], cnt)
                else:
                    d[p] = cnt
                di[i][p] = cnt

    ans = 0
    for i in range(N):
        b = 1
        for p in d:
            if p in di[i]:
                b *= pow(p, d[p]-di[i][p])
                b %= mod
            else:
                b *= pow(p, d[p])
                b %= mod
        ans += b
        ans %= mod
        
    return ans

if __name__ == '__main__':
    print(main())