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:
from math import gcd


def solve(n, ax):
    lcm = 1
    for ai in ax:
        lcm = lcm*ai//gcd(lcm, ai)
    m=lcm-1
    return sum(list(map(lambda x: (lcm-1)%x, ax)))


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

Submission status: Runtime Error

Solution code:
import math
n=int(input())
box=list(map(int,input().split()))
count=box[0]

for i in range(1,n):
    count=(box[i]*count)//math.gcd(box[i],count)

point=0
count -=1
for i in box:point +=count%i

print(point)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
n=int(input())
box=list(map(int,input().split()))

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

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

point=0
count=lcm_list(box)-1
for i in box:
    point +=count%i

print(point)

Submission status: Runtime Error

Solution code:
from functools import reduce
from operators import mul
 
n = int(input())
a = list(map(int, input().strip()))
 
m = reduce(mul, a) - 1
ans = 0
for ai in a:
  ans += m % ai
 
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
from operators import mul

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

m = reduce(mul, a) - 1
ans = 0
for ai in a:
  ans += mul % ai

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(*numbers):
    return reduce(lcm_base, numbers, 1)

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

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

j = lcm_list(a)

cnt = 0
for i in a:
    cnt += (j-1)%i

print(cnt)

Submission status: Runtime Error

Solution code:
n,a=open(0);print(eval(a.replace(" ","+")+"-"+n[:-1]))

Submission status: Runtime Error

Solution code:
n,a=open(0);print(eval(a.replace(" ","+")+"-"+n))

Submission status: Runtime Error

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

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

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

a_lcm=1
for i in range(n):
    a_lcm=lcm(a_lcm, a[i])

ans=0
for i in a:
    ans+=(a_lcm-1)%i
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = 0
x = [s += int(i) for i in input().split()]
print(s - n)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    lcm_a = lcm(*a)
    fm = sum([(lcm_a - 1) % ai for ai in a])
    return fm


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


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


if __name__ == "__main__":
    print(solve())

Submission status: Runtime Error

Solution code:
n = int(input())
array = [int(i) for i input().split()]

maxa = max(array)

answer =[]

for m in range(100000):
  sum = 0
  for i in range(n):
    sum += m%array[i]
  answer.append(sum)
  
print(max(answer))

Submission status: Runtime Error

Solution code:
from functools import reduce
import math

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

lcm = reduce(lambda x, y: (x * y) // math.gcd(x, y), A)

score = 0
for a in A:
    score += (lcm - 1) % a

print(score)

Submission status: Runtime Error

Solution code:
import os, sys, re, math

from functools import reduce
def lcm(vals):
    return reduce((lambda x, y: (x * y) // math.gcd(x, y)), vals, 1)

lines = sys.stdin.readlines()

n = int(lines[0])
a = [int(k) for k in lines[1].split()]

m = lcm(a) - 1
print (sum([m % k for k in a]))

Submission status: Runtime Error

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

lst.sort(reverse=True)
print(abs(lst[0] - lst[1]) + abs(lst[1] - lst[2]))

Submission status: Runtime Error

Solution code:
import math

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

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

Submission status: Runtime Error

Solution code:
from fractions import gcd


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


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

cumlcm = A[0]
for a in A[1:]:
    cumlcm = lcm(cumlcm, a)
m = cumlcm - 1
f = sum(map(lambda a: m % a if a != 0 else m, A))
print(f)

Submission status: Runtime Error

Solution code:
from fractions import gcd


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


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

cumlcm = A[0]
for a in A[1:]:
    cumlcm = lcm(cumlcm, a)
m = cumlcm - 1
f = sum(map(lambda a: m % a, A))
print(f)

Submission status: Runtime Error

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

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

n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
l = a[0]
for i in a[1:]:
    l = lcm(l, i)
print(sum(map(lambda x: (l - 1) % x, a)))

Submission status: Runtime Error

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

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

n = int(input())
a = sorted([int(i) for i in input().split()])
l = a[0]
for i in a[1:]:
    l = lcm(l, i)
print(sum(map(lambda x: (l - 1) % x, a)))

Submission status: Runtime Error

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

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

n = int(input())
a = [int(i) for i in input().split()]
l = a[0]
for i in a[1:]:
    l = lcm(l, i)
print(sum(map(lambda x: (l - 1) % x, a)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

from math import *

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

n = int(input())
A = [int(x) for x in input().split()]
m = 1
for i in A:
    m = lcm(i,m)

m -= 1
ans = 0
for i in A:
    ans += m%i

print(ans)

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:
import math
n=int(input())
a=[int(x) for x in input().split()]
x=1
for i in range(n):
    x=int(a[i]*x/math.gcd(a[i],x))

x-=1
ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
N = input()
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans += A[i]-1
print(ans)

Submission status: Runtime Error

Solution code:

###template###
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
As = [map(lambda x : int(x) - 1, input().split())]

print(sum(As))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
l = list(map,input().split())
print(sum(l)-n)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n = int(input())
l = list(map(int, input().split()))
m = l[0]
for i in range(1, n):
    m = m * l[i] // math.gcd(m, l[i])
m = m - 1
ans = 0
for i in l:
    ans += m % i
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

line = input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
temp = 0

for i, num in enumerate(num_list):
    if i+1 < len(num_list) -1:
        break
    temp = math.gcd(num, num_list[i + 1])


for num in num_list:
    ans += (temp-1) % num

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

# mはaの(最小公倍数 - 1)
lcm = a[0]
for item in a[1:]:
    lcm = (lcm * item) // math.gcd(lcm, item)
f = 0
for item in a:
    f += (lcm - 1) % item
print(f)

Submission status: Runtime Error

Solution code:
from itertools import accumulate
from math import gcd
def lcm_(x,y):
    return x*y//gcd(x,y)
def lcm(numbers):
    return list(accumulate(numbers,lcm_))
n=int(input())
A=[int(i) for i in input().split()]
L=lcm(A)[-1]-1
f=0
for i in A:
    f+=L%i

print(f)

Submission status: Runtime Error

Solution code:
n=int(input())
da=list(map((int,input().split()))
ans=0
for i in da:
  ans+=i-1
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
da=list(map((int,input().split()))
ans=0
fro i in range da:
  ans+=i-1
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(a[i],l)
s=0
l-=1
for i in range(n):
    s+=l%a[i]
print(s)

Submission status: Runtime Error

Solution code:
rom sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] // fractions.gcd(A[0], A[1]))

if len(A) > 2:
    for k in A[2:]:
        lcm_a = int(lcm_a * k // fractions.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Runtime Error

Solution code:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / fractions.gcd(A[0], A[1]))

if len(A) > 2:
    for k in A[2:]:
        lcm_a = int(lcm_a * k / fractions.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Runtime Error

Solution code:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / fractions.gcd(A[0], A[1]))

if len(A) > 2:
    for k in A[2:]:
        lcm_a = int(lcm_a * k / fractions.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Runtime Error

Solution code:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / fractions.gcd(A[0], A[1]))

for k in A[2:]:
    lcm_a = int(lcm_a * k / fractions.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Runtime Error

Solution code:
from sys import stdin
import math

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / math.gcd(A[0], A[1]))

for k in A[2:]:
    lcm_a = int(lcm_a * k / math.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Runtime Error

Solution code:
from sys import stdin
import math

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / math.gcd(A[0], A[1]))

for k in A[2:]:
    lcm_a = int(lcm_a * k / math.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd
input()
aa=list(map(int,input().split()))
lcm=reduce((lambda a,b:a*b//gcd(a,b)),aa)
m=lcm-1
print(sum(m%a for a in aa))

Submission status: Runtime Error

Solution code:
A,B,C = map(int,input().split())
abc = [A,B,C]
Even = []
Odd = []
for i in range(3):
    if min(abc) == abc[i]:
        idx1 = i
    elif max(abc) == abc[i]:
        idx3 = i
    else:
        idx2 = i
    if abc[i]%2 == 0:
       Even += [i]
    else:
       Odd += [i]
       
ans = 0

if len(Even) == 3 or len(Odd) == 3:
    ans = (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Even) == 2:
    ans += 1
    abc[Even[0]] += 1
    abc[Even[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Odd) == 2:
    ans += 1
    abc[Odd[0]] += 1
    abc[Odd[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
    
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
N = int(input())
A = list(map(int,input().split()))

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

l = A[0]
for i in range(1,N):
    l = lcm(l,A[i])
l -= 1

ans = 0
for a in A: ans += l % a
print(ans)

Submission status: Runtime Error

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

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)

Submission status: Runtime Error

Solution code:
gcd = lambda x, y: x if (y==0) else gcd(y, x%y)
lcm = lambda x, y: int(x*y/gcd(x, y))

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

gcd_all = 0
lcm_all = 1

for ai in A :
    gcd_all = gcd(gcd_all, ai)
    lcm_all = lcm(lcm_all, ai)

m = lcm_all - 1
print(sum(list(map(lambda ai: m%ai, A))))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def lcm_list(nums):
  return reduce(lcm, nums)
n = int(input())

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




m = lcm_list(a) - 1


ans = 0
for i in range(n):
  ans += m % a[i]
  
  
print(ans)

Submission status: Runtime Error

Solution code:
import math
 
N=int(input())
A=[int(i) for i in input().split()]
 
def Lcm(A):
    ans=A[0]
    for i in A[1:]:
        ans = ans * i // math.gcd(ans,i)
    return ans
 
m = Lcm(A)-1
ans = 0
 
for i in A:
    ans += m%i
    
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

def Lcm(A):
    ans=A[0]
    for i in A[1:]:
        ans = ans * i // math.gcd(ans,i)
    return ans

m = Lcm(A)-1
ans = 0

for i in A:
    ans += m%i
    
print(ans)

Submission status: Runtime Error

Solution code:
#ABC 103
import math
from functools import reduce

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
A = [int(j) for j in input().split()]

ans = 0
for a in A:
    ans+=(lcm(*A)-1)%a
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
A = [int(j) for j in input().split()]

print(lcm(*A)-1)

Submission status: Runtime Error

Solution code:
import copy
N = int(input())
ai = list(map(int, input().split()))

def lcm_list(l):
    if len(l) <= 1:
        return l[0]
    
    a = l.pop(len(l)-1)
    b = l.pop(len(l)-1)
    ans = lcm(a, b)
    l.append(ans)
    return lcm_list(l)

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

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

bi = copy.deepcopy(ai)
lcm_a = lcm_list(ai) - 1
ans = 0
for a in bi:
    ans += lcm_a % a

print(ans)

Submission status: Runtime Error

Solution code:
7
994 518 941 851 647 2 581

Submission status: Runtime Error

Solution code:
N = int(input())
L = list(map(int,input().split()))
def mod(m):
    if m == 0:
        return 0
    ans = 0
    for l in L:
        ans += m%l
    return max(ans,mod(m-1))
print(mod(max(L)*2))

Submission status: Runtime Error

Solution code:
N=int(input())
ans=0
for i in input().split():
  ans+=i
print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

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

a=lcm_list(l)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

def LCM(_a, _b):
  if _a < _b:
    a, b = _b, _a
  else:
    a, b = _a, _b
  while True:
    c = a%b
    if c==0:
      break
    a,b = b,c
  return (_a*_b)//b

def func(a_list):
  size = len(a_list)
  if size ==2:
    return LCM(a_list[0],a_list[1])
  else:
    return LCM(a_list[0], func(a_list[1:]))

lcm_1 = func(A)-1
print(sum(list(map(lambda x: lcm_1%x, A))))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
m=1
ans =0
def gcd(a, b):
 if a < b:
    a, b = b, a
 if b == 0:
    return a
 c = a % b
 return gcd(b, c)
def lcm(a,b):
    return int(a*b/gcd(a,b))
for i in range(n):
    m = lcm(m,a[i])
for i in range(m):
    sum = 0
    for j in range(n):
        sum += i % a[j]
    ans = max(ans,sum)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from functools import reduce
from math import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    lcd = 10
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from functools import reduce
from math import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    lcd = reduce(lambda i,j: i*j//gcd(i,j), A, 1)
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
from functools import reduce
from math import gcd
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    # 最小公倍数
    lcd = reduce(lambda i,j: i*j//gcd(i,j), A, 1)
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Runtime Error

Solution code:
N = int(input())
ANs = list(map(int,input().split()))
 
def lcm_base(x, y):
	return (x * y) // gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)
 
f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Submission status: Runtime Error

Solution code:
import math

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

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)

f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)

f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
	
lcmNum = lcm_list(ANs)
#print(lcmNum)
#print(lcmList)

f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Submission status: Runtime Error

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

import sympy
import math
from functools import reduce

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

def lcm_base(x, y):
	return (x * y) // math.gcd(x, y)
	
def lcm_list(numbers):
	return reduce(lcm_base, numbers, 1)
	
lcmNum = lcm_list(ANs)
lcmList = sympy.factorint(lcmNum)
#print(lcmNum)
#print(lcmList)


anss = []
f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
def gcm(a, b) :
  while(b) :
    a, b = b, a%b
  return a
def lcm(a, b) :
  return int(a*b/gcm(a, b))

b = a[0]
for i in range(n-1) :
  b = lcm(b, a[i+1])
  
print(sum([(b-1)%a[i] for i in range(n)]))

Submission status: Runtime Error

Solution code:
input();print(sum(int(a-1)for i in input().split()))

Submission status: Runtime Error

Solution code:
def solve(string):
    n, *a = map(int, string.split())
    return str(sum(a) - n)


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import imp
import os

import setuptools
from pkg_resources import parse_version
from setuptools import setup

if parse_version(setuptools.__version__) < parse_version('30.3.0'):
    raise RuntimeError('setuptools>=30.3.0 is required for "setup.cfg"')


def load_module(module_path):
    path = None
    for name in module_path.split('.'):
        file, path, description = imp.find_module(name, path)
        path = [path]
    return imp.load_module(name, file, path[0], description)


version = load_module('onlinejudge.__about__')

setup(
    name=version.__package_name__,
    version=version.__version__,
    author=version.__author__,
    author_email=version.__email__,
    url=version.__url__,
    license=version.__license__,
    description=version.__description__,
)

Submission status: Runtime Error

Solution code:
import numpy as np
N=int(input())
a=np.array(list(map(int,input().split())))

def f(m):
    ret=0
    for i in a:
        ret+=m%i
    return ret
  
def gcd_(a,b):
    if a<b:    a,b=b,a
    if b==0:    return a
    return gcd_(b,a%b)

def lcm_(x,y):
    return (x*y)//gcd_(x,y)

def lcm(l):
    ans=l[0]
    for i in l:
        ans=lcm_(ans,i)
    return ans
  
print(f(lcm(a)-1))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def lcm_base(x, y):
    return int((x * y)/math.gcd(x, y))
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def lcm_base(x, y):
    kakeru = x*y
    gcd = math.gcd(x,y)
    ans = kakeru//gcd
    return ans
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
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(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
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(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
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(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
print(ans)

Submission status: Runtime Error

Solution code:
import math
#引数にリストを入れるとその最小公倍数が返ってくる
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n=int(input())
A=list(map(int,input().split()))

k=1
for i in A:
  k=lcm(k,i)

def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(k-1))

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=list(map(int,input().split()))

def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(lcm_list(A)-1))

Submission status: Runtime Error

Solution code:
import math
import functools
def lcm(x,y):
  return(x*y)//math.gcd(x,y)

n=int(input())
A=list(map(int,input().split()))
num=functools.reduce(lcm,A)
def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(num-1))

Submission status: Runtime Error

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

n=int(input())
A=list(map(int,input().split()))
num=reduce(lcm,A)
def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(num-1))

Submission status: Runtime Error

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

n=int(input())
A=list(map(int,input().split()))
num=reduce(lcm,A)
ans=0
def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(num-1))

Submission status: Runtime Error

Solution code:
n=int(input())

X=list(map(int,input()))

print(sum(X)-n)

Submission status: Runtime Error

Solution code:
import math
import operator
from functools import reduce
N = int(input())
a_list = list(map(int, input().split(' ')))

def lcm_list(numbers):
    return reduce(operator.mul, numbers) // reduce(math.gcd, numbers)

m = lcm_list(a_list) - 1

print(sum([m % a for a in a_list]))

Submission status: Runtime Error

Solution code:
print(sum(i-1for i in map(int,open(0).read().split())[1:]))

Submission status: Runtime Error

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

def euclid(a, b):
    m = min(a,b)
    n = max(a,b)
    if (n%m==0):
        return m
    else:
        return euclid(m, n%m)

def sub_lcm(X):
    Y = []
    P, Q = len(X)//2, len(X)%2
    for p in range(P):
        a, b = X[2*p], X[2*p+1]
        y = a * b // euclid(a,b)
        Y.append(y)
    if Q!=0:
        Y.append(X[-1])
    return Y

def lcm(X):
    Y = sub_lcm(X)
    while len(Y)>1:
        Y = sub_lcm(Y)
    return Y[0]

y = lcm(A)-1
s = 0
for a in A:
    s += y%a
print(s)

Submission status: Runtime Error

Solution code:
# C
from functools import reduce

def lcm(a, b):
    return int(a*b/gcd(a, b))
def gcd(a,b):
    if a<b:a,b=b,a
    if a%b==0:return b
    return gcd(b,a%b)

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

result = 0
mod = int(reduce(lcm, a))-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

Submission status: Runtime Error

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

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

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

result = 0
mod = int(reduce(lcm, a))-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

Submission status: Runtime Error

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

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

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

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Submission status: Runtime Error

Solution code:
# C
from functools import reduce
from functools import lru_cache
import math

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

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

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Submission status: Runtime Error

Solution code:
# C
from functools import reduce
import math

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

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

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

Submission status: Runtime Error

Solution code:
import math
import functools


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

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

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

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)
result = 0
mod = lcm_list(a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

Submission status: Runtime Error

Solution code:
# C

import math
from functools import reduce


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

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)
result = 0
mod = lcm_list(a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)