Problem:


Score : 300 points

Problem Statement

You are given N positive integers a_1, a_2, ..., a_N.

For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).

Here, X\ mod\ Y denotes the remainder of the division of X by Y.

Find the maximum value of f.

Constraints

All values in input are integers.

2 \leq N \leq 3000

2 \leq a_i \leq 10^5

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

Print the maximum value of f.

Sample Input 1

3
3 4 6

Sample Output 1

10

f(11) = (11\ mod\ 3) + (11\ mod\ 4) + (11\ mod\ 6) = 10 is the maximum value of f.

Sample Input 2

5
7 46 11 20 11

Sample Output 2

90

Sample Input 3

7
994 518 941 851 647 2 581

Sample Output 3

4527



Sample input:
3
3 4 6


Sample output:
10

Submission status: Runtime Error

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

import math
import functools

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

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

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / gcd(x,y)), numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

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

import math
import functools

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

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

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / gcd(x,y)), numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

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

import math
import functools

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

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / math.gcd(x,y)), numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

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

import math
import functools

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

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

max_under_lcm = functools.reduce(lcm, numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

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

import math
import functools

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

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

max_under_lcm = functools.reduce(lcm, numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

Submission status: Runtime Error

Solution code:
n = input()
f = 0
an = input().split(" ")
dai = 0
wa = 0
for i in range(n):
    an[i] = int(a[i])
for i in range(1000000):
    for j in range(len(an-1)):
        wa = wa + m%an[j]
    if wa >= dai:
        dai = wa
print(dai)

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(input()) - 1 for _ in range(n)]
print(sum(a))

Submission status: Runtime Error

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

def f(m, a):
    return sum([m % i for i in a])

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

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

Submission status: Runtime Error

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

def f(m, a):
    return sum([m % i for i in a])

lcm = arr[0]
for i in range(1, len(arr)):
    lcm = lcm * arr[i] // math.gcd(lcm, arr[i])

print(f(lcm -1, arr))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

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

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

N = input()
N = int(N)
a=list(map(int,input().split()))
m = lcm(*a)
print(m)
x = 0
for j in range(N):
  x += (m-1) % a[j]
print(x)

Submission status: Runtime Error

Solution code:
import functools
import fraction

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

def slcm(numbers):
	return functools.reduce(blcm, numbers)
	
input()
numbers=list(map(int, input().split()))
num=slcm(numbers)-1
nums=[num%i for i in numbers]
print(sum(nums))

Submission status: Runtime Error

Solution code:
import functools
import math

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

def slcm(numbers):
	return functools.reduce(blcm, numbers)
	
input()
numbers=list(map(int, input().split()))
num=slcm(numbers)-1
nums=[num%i for i in numbers]
print(sum(nums))

Submission status: Runtime Error

Solution code:
import functools
import math

def slcm(numbers):
	return functools.reduce((lambda x,y:x*y//math.gcd(x, y)), numbers)
	
input()
numbers=list(map(int,input().split()))
num=slcm(numbers)-1
nums=[num%i for i in numbers]
print(sum(nums))

Submission status: Runtime Error

Solution code:
import functools
import math
def slcm(numbers):
	return functools.reduce((lambda x,y:x*y//math.gcd(x, y)), numbers)
	
input()
numbers=list(map(int,input().split()))
num=slcm(numbers)-1
nums=[num%i for i in numbers]
print(sum(nums))

Submission status: Runtime Error

Solution code:
import functools
import math
def slcm(numbers):
	return functools.reduce(lambda x,y:x*y//math.gcd(x,y),numbers)

input()
numbers=list(map(int,input().split()))
num=slcm(numbers)-1
print(sum([num%i for i in numbers]))

Submission status: Runtime Error

Solution code:
a=int(input())
print(sum(list(map(int,input())))-a)

Submission status: Runtime Error

Solution code:
n = int(input())
sum=0
for i in range(n):
    sum += int(input())
print(sum-n)

Submission status: Runtime Error

Solution code:
import math

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

def main():
    input()
    lcm = 1
    num_list = [int(i) for i in input().split()]
    for i in range(len(num_list)):
        lcm = func(num_list[i], lcm)
    lcm -= 1

    counter = 0
    for i in num_list:
        counter += (lcm % i)
    
    print(counter)

main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
a=[int(x) for x in input().split()]
import math
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    ans=numbers[0]
    for i in numbers:
        ans=math.gcd(ans,i)
    return ans
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
import math
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    ans=numbers[0]
    for i in numbers:
        ans=math.gcd(ans,i)
    return ans
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
import math
from functools import reduce
def prod(lists):
    ans=1
    for i in lists:
        ans=ans*i
    return ans
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
import math
from functools import reduce,partial
import operator
prod = partial(reduce, operator.mul)
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
import numpy as np
import math
from functools import reduce,partial
import operator
prod = partial(reduce, operator.mul)
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
import numpy as np
import math
from functools import reduce
def gcd(numbers):
    return reduce(math.gcd, numbers)
lcm=np.prod(a)//gcd(a)
print(sum([(lcm-1)%ai for ai in a]))

Submission status: Runtime Error

Solution code:
import math
n=int(input())
A=list(map(int,input().split()))
ans=1
for x in A:
    ans=ans*x//math.gcd(ans,x)
ans-=1
t=0
for x in A:
    t+=ans%x
print(t)

Submission status: Runtime Error

Solution code:
import sys
import fraction

dp = None
A = []

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

def f(m):
    ans = 0
    for a in A:
        ans += m % a
    return ans

def main():
    global A

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

    lcmtemp = 1

    for a in A:
        lcmtemp = lcm(lcmtemp, a)

    print(f(lcmtemp-1))

main()

Submission status: Runtime Error

Solution code:
import sys
import math

dp = None
A = []

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

def f(m):
    ans = 0
    for a in A:
        ans += m % a
    return ans

def main():
    global A

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

    lcmtemp = 1

    for a in A:
        lcmtemp = lcm(lcmtemp, a)

    print(f(lcmtemp-1))

main()

Submission status: Runtime Error

Solution code:
import sys
import math
import collections
import itertools
import array
from functools import reduce
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None
A = []

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

def f(m):
    ans = 0
    for a in A:
        ans += m % a
    return ans

def main():
    global A

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

    lcmtemp = 1

    for a in A:
        lcmtemp = lcm(lcmtemp, a)

    print(f(lcmtemp-1))

main()

Submission status: Runtime Error

Solution code:
input()
a=input().split(' ')
sum=0
for i in a:
    sum+=i-1
print(sum)

Submission status: Runtime Error

Solution code:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))

Submission status: Runtime Error

Solution code:
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))

Submission status: Runtime Error

Solution code:
n = int(input())
a=map(int, input().split())
print(sum(a) - len(a))

Submission status: Runtime Error

Solution code:
N = int(input())
L = [int(i) for i in input().split()]
print(sum(L - N) )

Submission status: Runtime Error

Solution code:
s=str(input())
t=str(input())
le=len(s)
for i in range(le):
	if s==t[:i]+t[i:]:
		print("Yes")
		return(0)
print("No")

Submission status: Runtime Error

Solution code:
import math

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

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

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

Submission status: Runtime Error

Solution code:
import math

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

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

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

mmax=llcm
fmmax=0
for m in range(mmax):
    fm=0
    for i in l:
        fm += m%i
    if fm > fmmax:
        fmmax=fm
print(fmmax)

Submission status: Runtime Error

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

a.sort()

for m in range(0,int(a[n])) :
    for j in range(0,n) :
        f[m] += m//a[j]

f.sort()

print(f[n])

Submission status: Runtime Error

Solution code:
print(-int(input())+sum(map(input().split(),int)))

Submission status: Runtime Error

Solution code:
from functools import reduce
import math

def solve(N, a):
	m = reduce(lambda x, y: x*y, a) // reduce(math.gcd, a) - 1
	ans = 0
	for ai in a:
		ans += m % ai
	return ans

if __name__ == '__main__':
	N = int(input())
	a = list(map(int, input().split()))
	print(solve(N,a))

Submission status: Runtime Error

Solution code:
#coding: utf-8

def get_gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

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

iN = int(input())
iAList = list(map(int, input().split()))

iKobaisu = iAList[0]
for i in range(1, iN):
    iA = iKobaisu
    iB = 1
    if not iAList[i] == 0:
        iB = iAList[i]
    if not int(get_gcd(iA, iB)) == 0:
        iKobaisu = int((iA * iB) / get_gcd(iA, iB))


iKobaisu -= 1

iModSum = 0
for i in range(iN):
    if not iAList[i] == 0:
        iModSum += (iKobaisu % iAList[i])

print (iModSum)

Submission status: Runtime Error

Solution code:
#coding: utf-8

def get_gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

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

iN = int(input())
iAList = list(map(int, input().split()))

iKobaisu = iAList[0]
for i in range(1, iN):
    iA = iKobaisu
    iB = iAList[i]
    if not int(get_gcd(iA, iB)) == 0:
        iKobaisu = int((iA * iB) / get_gcd(iA, iB))


iKobaisu -= 1

iModSum = 0
for i in range(iN):
    iModSum += (iKobaisu % iAList[i])

print (iModSum)

Submission status: Runtime Error

Solution code:
#coding: utf-8

def get_gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

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

iN = int(input())
iAList = list(map(int, input().split()))

iKobaisu = iAList[0]
for i in range(1, iN):
    iA = iKobaisu
    iB = iAList[i]
    iKobaisu = int((iA * iB) / get_gcd(iA, iB))

iKobaisu -= 1

iModSum = 0
for i in range(iN):
    iModSum += (iKobaisu % iAList[i])

print (iModSum)

Submission status: Runtime Error

Solution code:
#coding: utf-8

def get_gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

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

iN = int(input())
iAList = list(map(int, input().split()))

iKobaisu = iAList[0]
for i in range(1, len(iAList)):
    iA = iKobaisu
    iB = iAList[i]
    iKobaisu = int((iA * iB) / get_gcd(iA, iB))

iKobaisu -= 1

iModSum = 0
for i in range(len(iAList)):
    iModSum += (iKobaisu % iAList[i])

print (iModSum)

Submission status: Runtime Error

Solution code:
import math, sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def lcm_list(numbers):
    res = 1
    for num in numbers:
        res = lcm_base(res, num)
    return res


def calc_f(n, ms):
    s = 0
    for m in ms:
        s += n % m

    return s


n = int(input())
a = LI()

print(calc_f(lcm_list(a)-1, a))

Submission status: Runtime Error

Solution code:
#coding: utf-8

from fraction import gcd

iN = int(input())
iAList = list(map(int, input().split()))

iKobaisu = iAList[0]
for i in range(1, len(iAList)):
    iA = iKobaisu
    iB = iAList[i]
    iKobaisu = int((iA * iB) / gcd(iA, iB))

iKobaisu -= 1

iModSum = 0
for i in range(len(iAList)):
    iModSum += (iKobaisu % iAList[i])

print (iModSum)

Submission status: Runtime Error

Solution code:
#coding: utf-8

from math import gcd

iN = int(input())
iAList = list(map(int, input().split()))

iKobaisu = iAList[0]
for i in range(1, len(iAList)):
    iA = iKobaisu
    iB = iAList[i]
    iKobaisu = int((iA * iB) / gcd(iA, iB))

iKobaisu -= 1

iModSum = 0
for i in range(len(iAList)):
    iModSum += (iKobaisu % iAList[i])

print (iModSum)

Submission status: Runtime Error

Solution code:
import math

def calc(array):
    min = array[0]
    for i in range(1, len(array)):
        min = int(min * array[i] / math.gcd(min, array[i]))
    return min - 1

if __name__ == "__main__":        
    N = int(input())
    array = list(map(int, input().split()))
    # num = reduce(lcm_base, array, 1) - 1
    num = calc(array)
    count = 0
    for i in range(0, N):
        count += num % array[i]
    print(count)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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


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

lcm = lcm_list(a) - 1

out = 0
for i in a:
    out += lcm%i
print(out)

Submission status: Runtime Error

Solution code:
def calc(array):
    min = array[0]
    for i in range(1, len(array)):
        min = int(min * array[i] / math.gcd(min, array[i]))
    return min - 1

if __name__ == "__main__":        
    N = int(input())
    array = list(map(int, input().split()))
    # num = reduce(lcm_base, array, 1) - 1
    num = calc(array)
    count = 0
    for i in range(0, len(array)):
        count += num % array[i]
    print(count)

Submission status: Runtime Error

Solution code:
import math

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


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


temp = an[0]
for i in range(len(an)):
    temp = lcm(temp, an[i])

m = temp - 1

ret = 0
for a in an:
    ret += m % a

print(ret)

Submission status: Runtime Error

Solution code:
import math

def calc(array):
    min = array[0]
    for i in range(1, len(array)):
        min = int(min * array[i] / math.gcd(min, array[i]))
    return min - 1

if __name__ == "__main__":        
    N = int(input())
    array = list(map(int, input().split()))
    # num = reduce(lcm_base, array, 1) - 1
    num = calc(array)
    count = 0
    for i in range(0, len(array)):
        count += num % array[i]
    print(count)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(3001)

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

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

def lcm_list(li):
    if len(li) == 2:
        return lcm(li[0], li[1])

    else:
        li = [lcm(li[0], li[1])] + li[2:]
        return lcm_list(li)

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


i = max(lcm_list(a) - 1, 1)
print(sum([i % j for j in a]))

Submission status: Runtime Error

Solution code:

import math

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


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


temp = an[0]
for i in range(len(an)):
    temp = lcm(temp, an[i])

m = temp - 1

ret = 0
for a in an:
    ret += m % a

print(ret)

Submission status: Runtime Error

Solution code:
print((lambda a,b:sum(b)-a)(input(),list(map(int,input().split()))))

Submission status: Runtime Error

Solution code:
n = input()
a = list(map(int, input().split()))
fmax = 0
for i in range(sum(a)):
    f = 0
    for j in range(n):
        f += i % a[j]
    if f > fmax:
        fmax = f
print(fmax)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def mod_f(m):
    for i in range(N):
        n = 0
        n += m % a[i]

    return n

a = []
N = int(input())
for i in range(N):
    a.append(int(input()))

print(a)

lcm = lcm(a)
print(lcm)
m = lcm - 1

print(mod_f(m))

Submission status: Runtime Error

Solution code:
import functools
N = int(input())
ar = [int(i) for i in input().split()]
lim = functools.reduce(lambda x, y: x * y, ar)

nums = list(range(1,lim))
nums.reverse()
max = 0
for i in nums:
  result = sum([i % j for j in ar])
  if result > max:
    max = result
    
print(max)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

N = int(input())
a = list(map(int, input().split()))
ans = 0
num = lcm_list(a) - 1
for i in range(len(a)):
	ans += num % a[i]
print(ans)

Submission status: Runtime Error

Solution code:
n = input()
a = list(map(int, input().split()))
fmax = 0
    for i in range(sum(a)):
        f = 0
        for j in range(n):
            f += i % a[j]
        if f > fmax:
            fmax = f
print(fmax)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

N = int(input())
a = list(map(int, input().split()))
ans = 0
num = lcm_list(a) - 1
print(num)
for i in range(len(a)):
	ans += num % a[i]
print(ans)

Submission status: Runtime Error

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

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

if __name__ == "__main__":        
    N = int(input())
    array = list(map(int, input().split()))
    # num = reduce(lcm_base, array, 1) - 1
    num = lcm(*array)
    count = 0
    for i in range(0, len(array)):
        count += num % array[i]
    
    print(count)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

# gcd = functools.reduce(math.gcd, values)
m = reduce(lcm, a) - 1

f = 0
for ai in a:
    f = f + m%ai

print(f)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

def lcm_list(l):
    return reduce(lcm, l, 1)

fm = 0
m = lcm_list(a) - 1
for item in a:
    fm += m % item

print(fm)

Submission status: Runtime Error

Solution code:
import math, sys
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


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


def calc_f(n, ms):
    s = 0
    for m in ms:
        s += n % m

    return s


n = int(input())
a = LI()

print(calc_f(lcm_list(a)-1, a))

Submission status: Runtime Error

Solution code:
import fraction
from functools import reduce

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

def lcm(nums):
    return reduce(lcm_base, nums, 1)

n, a = input(), list(map(int, input().split()))
l = lcm(a)
sum = 0
for aa in a:
    sum += (l-1) % aa
print(sum)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def lcm(nums):
    return reduce(lcm_base, nums, 1)

n, a = input(), list(map(int, input().split()))
l = lcm(a)
sum = 0
for aa in a:
    sum += (l-1) % aa
print(sum)

Submission status: Runtime Error

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

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

def lcm_list(li):
    if len(li) == 1:
        return li[0]

    elif len(li) == 2:
        return lcm(li[0], li[1])

    else:
        li = [lcm(li[0], li[1])] + li[2:]
        return lcm_list(li)

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


i = max(lcm_list(a) - 1, 1)
print(sum([i % j for j in a]))

Submission status: Runtime Error

Solution code:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


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


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


def calc_f(n, ms):
    sum = 0
    for m in ms:
        sum += n % m

    return sum


n = I()
a = LI()

print(calc_f(lcm_list(a)-1, a))

Submission status: Runtime Error

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

def find_lcm(num1, num2):
    if(num1>num2):
        b = num1
        a = num2
    else:
        b = num2
        a = num1
    G = gcd(a,b)
    lcm = int(int(num1 * num2)/int(G))
    return lcm
     
N=int(input())
A=list(map(int,input().split()))
lcm = find_lcm(A[0],A[1])
for I in range(2, N):
    lcm = find_lcm(lcm, A[I])
Ans=0
lcm-=1
for I in range(N):
	Ans+=(lcm%A[I])
print(Ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split(" ")

max = a[0]
for i in range(1,n) :
    if max < a[i] :
        max = a[i]

f = 0
for j in range(1,int(max)) :
    for d in range(0,n) :
        f[j] += j//a[d]

max1 = 0
for i in range(1,int(max)):
    if max1 < f[i] :
        max1 = f[i]

print(max1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

if __name__ == "__main__":        
    N = int(input())
    array = list(map(int, input().split()))
    # num = reduce(lcm_base, array, 1) - 1
    num = lcm(*array)
    count = 0
    for i in range(0, len(array)):
        count += num % array[i]
    
    print(count)

Submission status: Runtime Error

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

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

def lcm_list(li):
    if len(li) == 1:
        return li[0]

    elif len(li) == 2:
        return lcm(li[0], li[1])

    else:
        li = [lcm(li[0], li[1])] + li[2:]
        return lcm_list(li)

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


i = max(lcm_list(a) - 1, 1)
print(sum([i % j for j in a]))

Submission status: Runtime Error

Solution code:
import math
import functools

def main() :
    lcm_base = lambda x, y : (x * y) // math.gcd(x, y)
    n = int(input())
    a = list(map(int, input().split()))
    lcm = int(functools.reduce(lcm_base, a))

    ans = 0
    for aa in a :
        ans += (lcm-1) % aa

    print(ans)

main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

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

m = lcm(*a) - 1

f = 0
for ai in a:
    f = f + m%ai

print(f)

Submission status: Runtime Error

Solution code:
import math
import functools

def main() :
    lcm_base = lambda x, y : (x * y) // math.gcd(x, y)
    n = int(input())
    a = list(map(int, input().split()))
    lcm = int(functools.reduce(lcm_base, a, 1))

    ans = 0
    for aa in a :
        ans += (lcm-1) % aa

    print(ans)

main()

Submission status: Runtime Error

Solution code:
import math
N = int(input())
a = input().split()
a = [int(i) for i in a]
res_list = {}
def lcm(x,y):
    return (x * y) // math.gcd(x, y)
for i in range(len(a)):
    if i == 0:
        res = a[i]
        continue
    else:
        res = lcm(res,a[i])
res2 = 0
for i in a:
    res2 += (res-1) % i
print(res2)

Submission status: Runtime Error

Solution code:
def gcd(x,y):
    if x > y:
        a = x
        b = y
    else:
        a = y
        b = x
    while a % b != 0:
        b = a % b
        a = b
    return b

input()
ip = input().split()
data = []
for i in ip:
    data.append(int(i))


def lcmbase(x, y):
    return x * y / gcd(int(x), int(y))

def lcm(num):
    buf = num[0]
    for i in range(1, len(num)):
        buf = lcmbase(num[i], buf)
    return buf

usedata = int(lcm(data) - 1)

suming = 0
for i in data:
    suming += usedata % i

print(suming)

Submission status: Runtime Error

Solution code:
import math
import fraction
from functools import reduce


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


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


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

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)

Submission status: Runtime Error

Solution code:
import math
import fraction
from functools import reduce


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


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


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

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)

Submission status: Runtime Error

Solution code:
import fractions

def lcm(lst):
    if len(lst) == 2:
        return (lst[0] * lst[1]) // fractions.gcd(lst[0], lst[1])
    l = lcm(lst[1:])
    return (lst[0] * l) // fractions.gcd(lst[0], l)

n = int(input())
inputs = list(map(int, input().split(' ')))
x = lcm(inputs) - 1
s = 0
for i in inputs:
    s += x % i
print(s)

Submission status: Runtime Error

Solution code:
import math

N = int(input())
a = list(map(int, input().split()))
ans = 0
num = 0
for i in range(1, len(a)):
	num *= int(a[i-1] * a[i] / math.gcd(a[i-1],a[i]))
num -= 1
for i in range(len(a)):
	ans += num % a[i]
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


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


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

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

if __name__ == "__main__":        
    N = int(input())
    array = list(map(int, input().split()))
    num = reduce(lcm_base, array, 1) - 1
    count = 0
    for i in range(0, len(array)):
        count += num % array[i]
    
    print(count)

Submission status: Runtime Error

Solution code:
import math

N = int(input())
a = list(map(int, input().split()))
ans = 0
num = 0
for i in range(1, len(a)):
	num *= a[i-1] * a[i] // math.gcd(a[i-1],a[i])
num -= 1
for i in range(len(a)):
	ans += num % a[i]
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
import functools

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

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

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

max = 0
M = lcm_list(a)
for i in range(0, M):
    ans = 0
    for j in range(0, N):
        ans += i % a[j]
    if max < ans:
        max = ans

print (max)

Submission status: Runtime Error

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

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

def lcm_list(numbers):
    a_0 = numbers.pop()
    for i in numbers:
        a_0 = lcm_base(a_0, i)
    return a_0

b = a.copy()
m = lcm_list(b)-1
sum = 0
for j in a:
    sum += m%j

print(sum)

Submission status: Runtime Error

Solution code:
import sys

# 最大公約数
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())).sort()

lcm_num = lcm(a[0], a[1])

for i in range(2, n):
    lcm_num = lcm(lcm_num, a[i])

ans = 0
for i in range(n):
    ans += (lcm_num-1) % a[i]

print(int(ans))