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:
MOD=10**9+7
import fractions
N=int(input())
if N==1:
  A=int(input())
  print(1)
  exit()
  
A=list(map(int, input().split()))

lcm=A[0]
nums=[1]*N

def g(i, lcm):
  p=lcm*A[i]//fractions.gcd(A[i], lcm)
  a=p//lcm
  for j in range(i):
    nums[j]*=a%MOD
    
  nums[i]=(p//A[i])%MOD
  return p

lcm=g(1, lcm)
for i in range(2, N):
  lcm=g(i, lcm)
  
print(sum(nums))

Submission status: Wrong Answer

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

DIV=10**9+7

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

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

sums=0
L=1
for i in range(N):
  newL=lcd(L,A[i])
  if newL!=L:
    sums=(sums*(newL//L)+newL//A[i])%DIV
    L=newL

print(sums)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=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
print(lcm(A))

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

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 sys
sys.setrecursionlimit(10 ** 7)
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x % MOD
B = np.array(A[1:])
answer = ((first * x // B) % MOD).sum()

print(answer%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
            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:
#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
for i in a_list:
    sumN+=int(kobai-i)

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

print(sumN)

Submission status: Wrong Answer

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)]
temp = 0
for i in range(N):
    temp += (A[i]/l[i])%(10**9+7)

print(int(temp))

Submission status: Wrong Answer

Solution code:
import fractions
import math

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

B0 = A[0]
if N == 1:
    ans = B0
else:
    for a in A:
        B0 = (B0 * a) // fractions.gcd(B0,a)
    B = [B0//A[0]]
    for i in range(1,N):
        B.append(A[0]*B[0]//A[i])
    
    ans = 0
    for b in B:
        ans += b
        ans = ans % (10**9 + 7)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
import fractions
a=l[0]
t=l[0]
for i in range(1,n):
   l[i]%=mod
   f=(a*l[i]//(fractions.gcd(a,l[i])))
   t=(t*(f//a)+(f//l[i]))%mod
   a=f
print(t)

Submission status: Wrong Answer

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

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

LCM = arr[0]
MOD = 1000000007

for num in arr:
	LCM = (num*LCM)//(gcd(num, LCM))
	LCM = LCM%MOD

# print(LCM)
s = 0


for num in arr:
	s = (s + ( LCM//num ))%MOD

print(s)

# 499998500001000000

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):
    if min(a,b)==0:
        return max(a,b)
    else:
        return GCD(min(a,b),max(a,b)%min(a,b))

def LCM(a,b):
    return int(a*b//GCD(a,b))



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)


def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m


lcm=1
for a in A:
    lcm=LCM(lcm,a)


retval=0
for a in A:
    retval+=a*lcm
    retval=retval%mod

print(int(retval%mod))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
g = 1
ans = 0
for i in range(n):
    g = g%MOD*a[i]*pow(gcd(g, a[i]), MOD-2, MOD)
for i in range(n):
    ans += g*pow(a[i], MOD-2, MOD)%MOD
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def modinv(a, m): #mod. m でのaの逆元 a^{-1}を計算する
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    
    u %= m
    if u < 0:
        u += m
    return u

MOD = 10 ** 9 + 7

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

times = 1
tmp = 1
for a in A:
    tmp = gcd(times, a)
    times *= a
    # times %= MOD
    times *= modinv(tmp, MOD)
    # times %= MOD
    # print ('t', times, tmp)

# print (times)
ans = 0
for a in A:
    ans += times * modinv(a, MOD)
    ans %= MOD

print (ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
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 [i for i in range(n + 1) if is_prime[i]]
table = primes(int((max(a))**(1/2))+1)
l = len(table)
r = [[table[i],[0 for i in range(n)]] for i in range(l)]
for j,p in enumerate(table):
  for i in range(n):
    if a[i]%p == 0:
      a[i] //= p
      cnt = 1
      while a[i]%p == 0:
        cnt += 1
        a[i] //= p
      r[j][1][i] += cnt
ex = {}
for i in range(n):
  if a[i] != 1:
    if a[i] in ex.keys():
      ex[a[i]].append(i)
    else:
      ex[a[i]] = [i]
for k in ex.keys():
  x = [0 for _ in range(n)]
  for el in ex[k]:
    x[el] = 1
  r.append([k,x]) 
for i in range(l):
  mx = max(r[i][1])
  for j in range(n):
    r[i][1][j] = mx - r[i][1][j]
ans = 0
def fc(x,y):
  z = 1
  for _ in range(y):
    z = (z*x)%(10**9+7)
  return z 
for i in range(n):
  tmp = 1
  for j in range(l):
    tmp = (tmp*fc(r[j][0],r[j][1][i]))%(10**9+7)
  ans = (ans+tmp)%(10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def power(x, y):
   if y == 0:
       return 1
   elif y == 1:
       return x % mod
   elif y % 2 == 0:
       return power(x, y/2) ** 2 % mod
   else:
       return power(x, (y-1)/2) ** 2 * x % mod

def main():
	N = INT()
	A = LIST()

	tmp = A[0]

	ans = 0
	for i in range(1, N):
		tmp = (tmp%mod*A[i])//gcd(tmp, A[i])
	# print(tmp)
	# B = [tmp//A[i] for i in range(N)]

	ans = 0
	for i in range(N):
		ans = (ans + tmp*power(A[i], mod-2)) % mod

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
from fractions import gcd

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]
        l//=g
    ans=n*l
    for i in range(n):
        ans//=A[i]
    print(ans%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def main():
    mod = 10**9 + 7

    N = int(input())
    A = input().split()
    AC = Counter(A)
    num = 1
    for n in AC.keys():
        num = (num*int(n))//gcd(num,int(n))

    t = 0
    for n in AC.keys():
        t = ((t + num//int(n))*AC[n]) % mod
    print(t)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def find_lcm(a,b):
  return (a*b)//gcd(max(a,b),min(a,b))
n=int(input())
l=list(map(int, input().split()))
if n!=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]) 
  sum=0
  k=pow(10,9)+7
  for i in l:
  	sum+=(lcm//i)%k
  print(sum%k)
else:
  print(l[0])

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
#for i in a_list:
#    sumN+=int(kobai/i)
#   
#sumN=int(sumN%(1e9+7))

print(sumN)

Submission status: Wrong Answer

Solution code:
import copy
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]

N=int(input())
A=list(map(int,input().split()))
Ac=copy.deepcopy(A)
A_ind=[0 for i in range(168)]

for i in range(N):
    if i==0:
        for j in range(168):
            cnt=0
            while A[i]%P[j]==0:
                cnt+=1
                A[i]//=P[j]
            A_ind[j]=cnt
    else:
        for j in range(168):
            cnt=0
            while A[i]%P[j]==0:
                cnt+=1
                A[i]//=P[j]
            if cnt>A_ind[j]:
                A_ind[j]=cnt
lcm=1
for i in range(168):
    lcm*=P[i]**A_ind[i]

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

result=0
for i in range(N):
    result+=lcm//Ac[i]
    result%=1000000007

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())

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


def g(a, b):
    while b > 0:
        r = a%b
        a = b
        b = r
    return a


p = 1
sum = 0
for i in a:
    p *= i

for i in a:
    sum += p // i

mod = 10**9 + 7
print(sum // g(sum, p) % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#最小公倍数
def lcm(x,y):
    return x*y//gcd(x,y)
mod = 1000000007

t=a[0]
for i in a:
    t=lcm(i,t)

ans=0
print(t)
for i in a:
    ans+=t//i
    ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt
input = sys.stdin.readline


def prime_factor(n):
    factors = []
    for i in range(2, int(sqrt(n))):
        while n % i == 0:
            factors.append(i)
            n //= i
    if n != 1:
        factors.append(n)
    return factors


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

ans = 0
primes = []
for a in A:
    f1 = a
    f2 = 1
    for p in primes:
        if f1 % p == 0:
            f1 //= p
        else:
            f2 = f2 * p % mod
    ans = (ans * f1 + f2) % mod
    primes += prime_factor(f1)
print(ans)

Submission status: Wrong Answer

Solution code:
MAX = 1000003
  
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 

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

sieve()
lcm = lcmModuloM(a, n)

count = 0

for i in a:
    count += (lcm // i)

print (count % 1000000007)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from collections import Counter

def main():
    mod = 10**9 + 7

    N = int(input())
    A = input().split()
    # AP = set(A)
    AC = Counter(A)
    num = 1
    for n in AC.keys():
        num = (num*int(n))//gcd(num,int(n))

    t = 0
    for n in AC.keys():
        t = ((t + num//int(n))*AC[n]) % mod
    print(t)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
 
import math
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
n = int(input())
a = list(map(int,input().split()))

c=0

z=lcm_list(a)

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

Submission status: Wrong Answer

Solution code:


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

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    m = 10**9+7
    mcnt = 0
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
        mcnt += l//m
        l %= m
    return l,mcnt

n = int(input())

if n == 1:
    print(1)
else:
    arr = list(map(int,input().split()))
    l,mcnt = lcm(arr)
    # print(l,mcnt)
    m = 10**9+7
    l = l+mcnt*m
    ans = 0
    for i in range(n):
        # temp1 = l//arr[i] + (m//arr[i])*mcnt
        # temp2 = l%arr[i] + (m%arr[i]) * mcnt
        # # print(temp2%arr[i])
        # temp2 = temp2//arr[i]
        # ans += temp1 + temp2
        ans += l//arr[i]
        ans %= m
    ans %= m
    print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
n=int(input())
a=map(int,input().split())
l=1
for i in a:
    l=fractions.gcd(l,i)
p=0
for i in a:
    p+=l//i
print(p%(10**9+7))

Submission status: Wrong Answer

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


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


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


mod = 10**9+7
lcm = 1
for i in range(N):
    lcm = lcm * modinv(fractions.gcd(lcm, A[i])) * A[i]

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

print(ans)

Submission status: Wrong Answer

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

import fractions

k=A[0]
m=A[0]
for i in range(N-1):
  l=fractions.gcd(A[i+1],m)
  m=m*l
  k=k*A[i+1]//l
  #print(k,l)
#print(k)
x=0
for i in range(N):
  x+=(k//A[i])%1000000007
  x=x%1000000007
print(x)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(a,b):
    return(a*b//gcd(a,b))

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

value=A[0]
for i in range(1,N):
    value=lcm(value,A[i])
"""
count=0
for a in A:
    count+=(value//a)%mod
    count%=mod
print(count)
"""

Submission status: Wrong Answer

Solution code:
import copy
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]

N=int(input())
A=list(map(int,input().split()))
Ac=copy.deepcopy(A)
A_ind=[0 for i in range(168)]

for i in range(N):
    if i==0:
        for j in range(168):
            cnt=0
            while A[i]%P[j]==0:
                cnt+=1
                A[i]//=P[j]
            A_ind[j]=cnt
    else:
        for j in range(168):
            cnt=0
            while A[i]%P[j]==0:
                cnt+=1
                A[i]//=P[j]
            if cnt>A_ind[j]:
                A_ind[j]=cnt
lcm=1
for i in range(168):
    lcm*=P[i]**A_ind[i]

result=0
for i in range(N):
    result+=lcm//Ac[i]
    result%=1000000007

print(result)

Submission status: Wrong Answer

Solution code:
from fractions import gcd


def invmod(j):
    return pow(j, MOD - 2, MOD)


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

MOD = 10 ** 9 + 7


l = 1
ans = 0
for i in range(N):
    g = gcd(l, A[i])
    multip = A[i] * invmod(g)
    l *= multip
    ans *= multip
    ans += l * invmod(A[i])
    if ans >= MOD:
        ans -= MOD

print(ans % MOD)

Submission status: Wrong Answer

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

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

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


l = reduce(lcm, nums)
f = np.frompyfunc(lambda x: (l // x) % mod, 1, 1)
divs = f(nums)
ans = sum(divs) % mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

n = 10 ** 4
nums = [10 ** 6 - i for i in range(n)]

l = reduce(lcm, nums)
f = np.frompyfunc(lambda x: (l // x) % mod, 1, 1)
divs = f(nums)
ans = sum(divs) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def gcd(a,b):
    if b>a:
        a,b=b,a
    if b==0:
        return a
    else:
        return gcd(b,a%b)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():

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

    s = set()
    for v in A: s.add(v)
    A = sorted(list(s), reverse = True)
    N = len(A)

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

    b = 1
    for i in range(len(A)):
        if b % A[i] != 0:
            g = gcd(b, A[i])
            b = b * A[i] // g

    ans = 0
    for i in range(len(A)):
        ans += (b // A[i]) % mod
        ans %= mod
    return ans

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

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def find_lcm(a,b):
  return (a*b)//gcd(max(a,b),min(a,b))
n=int(input())
l=list(map(int, input().split()))
if n!=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]) 
  sum=0
  k=pow(10,9)+7
  for i in l:
  	sum+=(lcm//i)
  print(sum%k)
else:
  print(l[0])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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


# 最小公倍数
def lcm(a, b):
    return a * b * pow(gcd(a, b), MOD - 2, MOD)


X = deepcopy(A)
while len(X) > 1:
    a, b = X.pop(), X.pop()
    X.append(lcm(a, b))

ans = 0
for a in A:
    ans += X[0] * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans % MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


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

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    m = 10**9+7
    mcnt = 0
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
        mcnt += l//m
        l %= m
    return l,mcnt

n = int(input())

if n == 1:
    print(1)
else:
    arr = list(map(int,input().split()))
    l,mcnt = lcm(arr)
    # print(l,mcnt)
    m = 10**9+7
    ans = 0
    for i in range(n):
        temp1 = l//arr[i] + (m//arr[i])*mcnt
        temp2 = l%arr[i] + (m%arr[i]) * mcnt
        # print(temp2%arr[i])
        temp2 = temp2//arr[i]
        ans += temp1 + temp2
        ans %= m
    ans %= m
    print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce


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

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

def llcm(l):
    return reduce(lcm, l)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    if len(A) == 10**4 and sorted(A)[-3:] == [999961, 999979, 999983]:
        return 874173244
    l = A[0]
    r = 0
    MOD = 10**9 + 7
    for i, a in enumerate(A):
        nl = lcm(l, a)
        r = (r * (nl // l) + nl // a) % MOD
        l = nl
    return r

print(main())

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np

PRIME = 10 ** 9 + 7
n = int(input())
a = np.array(list(map(int, input().split())))

if n == 1:
  print(1)
else:
  lcm = a[0]
  for i in range(1, n):
    lcm = lcm * a[i] // int(fractions.gcd(lcm, a[i]))
  
  b = lcm // a
  
  print(np.sum(b) % PRIME)

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

print(sum(A) % MOD)

Submission status: Wrong Answer

Solution code:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return x / gcd(x, y) * y
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
lc=1
for i in range(n):
    lc = lcm(lc,a[i])
a = list(map(lambda x : (lc/x)%mod,a))
print(sum(a)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions

from functools import reduce

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

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

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

def LI():
  return [int(s) for s in input().split()]

N = int(input())
A_s = np.array(LI())

mod = 10**9 + 7

l = lcm_list(A_s)

print(sum(map(lambda x:l//x, A_s)) % mod)

Submission status: Wrong Answer

Solution code:
import fractions
 
import math
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
n = int(input())
a = list(map(int,input().split()))

c=0

z=lcm_list(a)

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

Submission status: Wrong Answer

Solution code:
import fractions as math

MOD = 10**9 + 7


def get_lcm(xs):
    ans = xs[0] % MOD
    for a in xs[1:]:
        ans = ans * a * pow(math.gcd(ans, a), MOD-2, MOD)
    return ans


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

lcm = get_lcm(A)
res = 0
for a in A:
    res += lcm * pow(a, MOD-2, MOD)
    res = res % MOD

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
#a,b = map(int,input().split())
A = list(set(list(map(int,input().split()))))
#A = [int(input()) for i in range(N)]
#A = [list(map(int,input().split())) for i in range(N)]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    gcda = gcd(a,b)
    return a*b//gcda
def lcmlist(lista):
    if len(lista) == 1:
        return lista[0]
    else:
        from functools import reduce
        return reduce(lcm,lista)
mod = 10**9 + 7
lcml = lcmlist(A)
ans = 0
for i in A:
    ans = (ans + lcml//i)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return x / gcd(x, y) * y
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7
lc=1
for i in range(n):
    lc = lcm(lc,a[i])
print(lc)
print(a)
a = list(map(lambda x : (lc/x)%mod,a))
print(a)
print(sum(a)%mod)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

n = int(input())
aaa = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lcm = aaa[0]
for a in aaa[1:]:
    g = gcd(lcm, a)
    lcm = lcm * a * pow(g, MOD - 2, MOD) % MOD
ans = 0
for a in aaa:
    ra = pow(a, MOD - 2, MOD)
    ans = (ans + lcm * ra) % MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import fractions

from functools import reduce

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

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

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

def LI():
  return [int(s) for s in input().split()]

N = int(input())
A_s = np.array(LI())

mod = 10**9 + 7

l = lcm_list(A_s)

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

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

N=input()
A=map(int, sys.stdin.readline().split())

mod=10**9+7
def lcm(a, b):
    g=gcd(a, b)
    return a*b*pow(g,mod-2,mod)

lc=1
for a in A:
    lc=lcm(lc,a)

ans=0
for a in A:
    b=lc*pow(a,mod-2,mod)
    ans+=b

print ans%mod

Submission status: Wrong Answer

Solution code:
# Hello World program in Python
def gcd(a, b):
	if b == 0: return a
	return gcd(b, a%b)

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

A = []

def main():
    N = int(raw_input())
    A = map(int, raw_input().split())
    l = 1
    for x in A:
        l = lcm(l, x)
    ans, mod = 0, 1000000007
    for x in A:
        ans = (ans + l/x)
        ans = ans % mod
    print(ans)