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:
#最小公倍数でループ
import math
n = int(input())
ans = list(map(int,input().split()))
lcm = ans[0]
for k in ans:
    gcd = math.gcd(lcm, k)
    lcm = int(lcm*k/gcd)
#print(lcm)

an =0
for k in ans:
    an += (lcm-1)%k
        
print(an)

Submission status: Runtime Error

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

import math
A_=list(set(A))

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

lcm_ = A_[0]

for a_idx in range(1,len(A_)):
    lcm_ = lcm(lcm_,A_[a_idx])
    
lcm_ = lcm_-1
lcm_

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

Submission status: Runtime Error

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
N = int(input())
a = [int(i) for i in input().split(" ")]

x = lcm_list(a)-1
Sum = 0
for a_ in a:
    Sum += x%a_
print(Sum)

Submission status: Runtime Error

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

ans = 0

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

    max_ans = max(max_ans,ans)

print(max_ans)

Submission status: Runtime Error

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

m=1
for i in a:
  m*=i
f=0
m-=1
for i in a:
  f+=m%i  
print(max(f))

Submission status: Runtime Error

Solution code:
from math import gcd
a = [7, 46, 11, 20,11]   #will work for an int array of any length
lcm = a[0]-1
for i in a[1:]:
  lcm = lcm+i-1
print (lcm)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

#最小公倍数-1
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

MaxKoubai = lcm_list(a)
m = MaxKoubai - 1
result = 0

for i in range(N):
    result += m % a[i]
    
print(result)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

#m = 最小公倍数 - 1
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

MaxKoubai = lcm_list(a)
m = MaxKoubai - 1
result = 0

for i in range(N):
    result += m % a[i]
    
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

n=int(input())
a=list(map(int,input().split()))
b=lcm_list(a)
y=0
for x in a:
    y+=x-1
print(y)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,ans,a;
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>a;
        ans+=a-1;
    }
    cout << ans;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# ans

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import math
from functools import reduce
sys.setrecursionlimit(10**6)

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

#b=1
#for i in range(n):
#    b*=a[i]

def lcm_base(x,y):
    return (x*y)//math.gcd(x,y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
c=lcm_list(a)

#print(b)
#print(c)

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

#ans=0
##for i in range(b):
#for i in range(c):
#    f=0
#    for j in range(n):
#        f+=(i+1)%a[j]
#    ans=max(ans,f)

print(ans)

Submission status: Runtime Error

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

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

b=lcm_list(a)-1
ans=0
for i in a:
    tmp=b%i
    ans+=tmp
print(ans)

Submission status: Runtime Error

Solution code:
import math
n=int(input())
A=list(map(int,input().split()))
gd=1
tmp=A[0]
for i in range(n-1):
    gd=math.gcd(A[i+1],A[i])
    tmp*=A[i+1]
lcm=tmp//gd
lcm-=1
ans=0
for a in A:
    ans+=lcm%a

print(ans)

Submission status: Runtime Error

Solution code:
import math
import functools
n=int(input())
a=list(map(int,input().split()))
tmp=1
for f in a:
    tmp*=f
gcd=functools.reduce(math.gcd, a)
lcm=tmp//gcd
lcm-=1
ans=0
for f in a:
    ans+=lcm%f
print(ans)

Submission status: Runtime Error

Solution code:
n= int(input())
a =list(map(int,input().split()))
ans = a[0]

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

for i in range(n-1):
    ans = ans*a[i+1] / gcd(ans,a[i+1])
sum = 0
for i in range(n):
    sum += (ans-1)%a[i]
print(int(sum))

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = tuple(map(int, input().split()))
l = np.lcm.reduce(A) - 1

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

Submission status: Runtime Error

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


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

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

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

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

Submission status: Runtime Error

Solution code:
import math

def lcm(a, b):
    return (a * b) // math.gcd(a, b)
l = 1
n = int(input())
arr = [int(i) for i in input().split()]
for i in arr:
    l = lcm(i, l)
ans = 0
for i in arr:
    ans += (l - 1) % i
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
#from collections import deque
# from math import factorial
# import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
n = input()
#n, m = list(map(int, input().split()))
a = 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)


b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
import math
import sys
sys.setrecursionlimit(2000000)
n = input()
a = 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)
b = lcm_list(a)-1
f = 0
for i in a:
    f += b % i

print(f)

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in s))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
ans=0
if k%2==1:
    ans=(n//k)**3
    print(ans)
else:
    print((n//k)**3+(n+(k//2)//k)**3)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import math

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

def solve(N: int, a: "List[int]"):
    a_lcm = a[0]
    for i in range(1,N):
        a_lcm = lcm(a_lcm,a[i])
    
    l = []
    for m in range(a_lcm):
        sum = 0
        for i in range(N):
            sum += m % a[i]
        l.append(sum)

    print((sorted(l,reverse=True))[0])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
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)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)

Submission status: Runtime Error

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

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(l)-1
for i in range(n):
    k+=m%l[i]
print(k)

Submission status: Runtime Error

Solution code:
from fractions import gcd
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)
k=0
m=lcm_list(l)-1
for i in range(n):
    k+=m%l[i]
print(k)

Submission status: Runtime Error

Solution code:
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)
k=0
m=lcm_list(l)-1
for i in range(n):
    k+=m%l[i]
print(k)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
A = list(map(int,input().rstrip().split(' ')))
def lcm(a,b):
  return int(a*b//math.gcd(a,b))
L=1
for x in A:
  L=lcm(L,x)
L-=1
ans=0
for x in A:
  ans+=L%x
print(ans)

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().rstrip().split(' ')))
def lcm(a,b):
  return int(a*b//math.gcd(a,b))
L=1
for x in a:
  L=lcm(L,x)
L-=1
ans=0
for x in a:
  ans+=L%a
print(ans)

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)

res = 0
tmp = reduce(lcm,a)-1
for i in a:
    res += tmp % i
print(res)

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

res = 0
tmp = reduce(lcm,a)-1
for i in a:
    res += tmp % i
print(res)

Submission status: Runtime Error

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

saidai = 0
for i in range(min(A), Max(A)*2):
    cnt = 0
    for j in range(N):
        cnt += i%A[j]
    saidai = max(saidai, cnt)

print(saidai)

Submission status: Runtime Error

Solution code:
from functools import reduce
from fractions import gcd
n = input()
a = list(map(int,input().split()))
gd = reduce(gcd,a)
m = reduce(lambda a,b: a*b,a)/gd -1
sum = sum(map(lambda x: m%x,a))

print(int(sum))

Submission status: Runtime Error

Solution code:
from numpy import array,lcm
n = input()
a = array([int(e) for e in input().split()])
m = lcm.reduce(a) - 1
sum = 0

for i in range(len(a)):
    sum += m%a[i]

print(sum)

Submission status: Runtime Error

Solution code:
import numpy as np
n = input()
a = np.array([int(e) for e in input().split()])
m = np.lcm.reduce(a) - 1
sum = 0

for i in range(len(a)):
    sum += m%a[i]
print(sum)

Submission status: Runtime Error

Solution code:
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)

x = lcm(*a)

x = x - 1
result = 0
for i in a:
    result += x % i

print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,(input().split())))
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)

x = lcm(*a)

x = x - 1
result = 0
for i in a:
    result += x % i

print(result)

Submission status: Runtime Error

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

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

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

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()))
m = lcm(*a) - 1
ans = 0
for i in range(N):
  ans += m%a[i]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = lis(map(int, input().split()))

    main(n, a)

Submission status: Runtime Error

Solution code:
def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]

    main(n, a)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
A = list(map(int, input().split()))

lcm = np.lcm.reduce(A)
ans = ((lcm - 1) % A).sum()
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
A = list(map(int, input().split()))

print(A)
lcm = np.lcm.reduce(A)
ans = ((lcm - 1) % A).sum()
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

from fractions import gcd 

x =1
for i in l:
    x=int(x * i / gcd(x, i))

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(y)

Submission status: Runtime Error

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

from fractions import gcd 

x =l[0]
for i in range(1,n):
    x=int(x * l[i] / gcd(x, l[i]))

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(y)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
def function(m, a):
  count = 0
  for i in a:
    count += m%i
  return count
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
max_num = lcm(*a)-1
print(function(max_num, a))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def b(x, y):
    return (x * y) // math.gcd(x, y)
_ = int(input())
a = [int(x) for x in input().split()]
m = reduce(b, a, 1) - 1
print(sum([m % a_i for a_i in a]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

def gcd2(number):
    return reduce(gcd, number)

def lcm(x, y):
    return x * y // gcd(x, y)
def lcm2(number):
    return reduce(lcm, number)

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

Submission status: Runtime Error

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

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

def gcd2(number):
    return reduce(gcd, number)

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

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

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce


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


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


n = int(input())
a = list(map(int, input().split()))
ll = lcm_list(a) - 1
ans = 0
for i in a:
    ans += (ll % i)
print(ans)

Submission status: Runtime Error

Solution code:
# 2020/02/11
# AtCoder Beginner Contest 103 - C

import math
import fractions

# Greatest Common Divisor(GCD)  
def gcd_fgf(a, b):
    return fractions.gcd(a, b)

# Least Common Multiple(LCM)
def lcm_fgf(a, b):
    return int(a * b / fractions.gcd(a, b))

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

# Calc Co-LCM
work_lcm = a[0]
for i in range(1, n):
    work_lcm = lcm_fgf(work_lcm, a[i])

m = work_lcm - 1

# Sum remains
fm = 0
for i in range(n):
    fm = fm + (m % a[i])

ans = fm    
# Output
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

def lcm(ls):
  return reduce(lcm_base,ls)

print(lcm(a)-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

def gcd(m, n):
	if n == 0:
		return m
	return gcd(n, m % n)

def lcm(m, n):
	return m * n // gcd(m, n)

n = ni()
a = na()

l = a[0]
for i in range(n):
	l = lcm(l, a[i])

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

print(ans

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(sum(AN)-N)

Submission status: Runtime Error

Solution code:
#AtCoder
N = int(input())
a = list(map(int, input()))

print(sum(a)-N)

Submission status: Runtime Error

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

print(sum(a)-n)

Submission status: Runtime Error

Solution code:
import sys
import math


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


def input():
    return sys.stdin.readline().strip()


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

a_lcm = a[0]
for ai in a:
    a_lcm = lcm(ai, a_lcm)

m = a_lcm - 1
ans = 0

for ai in a:
    ans += m%ai

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

n = int(input())
v = [int(x) for x in input().split()]
running = 1
for x in v:
  running = lcm(running,x)
print(x-1)

Submission status: Runtime Error

Solution code:
import fractions as math

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

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

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

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Submission status: Runtime Error

Solution code:
import fractions as math

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

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

if n == 1:
    print(list1[0]-1)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Submission status: Runtime Error

Solution code:
import fractions as math

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

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

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

m = 1

for i in a:
    m = lcm(m, i)

m -= 1
ans = 0

for e in a:
    ans += m % e

print(ans)

Submission status: Runtime Error

Solution code:
import sys
readline = sys.stdin.readline
n = int(readline())
print(sum([int(i) for i in readline().split()] - n)

Submission status: Runtime Error

Solution code:
N = int(input())
print(eval(input().replace(" ", "+")) - N)

Submission status: Runtime Error

Solution code:
print(-int(input())+sum(int(i) for i in input().split())))

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

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

lcm = lcm_list(l)
a = lcm-1
mod_all = 0

for i in l:
    mod_all += a%i

print(mod_all)

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_L = list(map(int,input().split()))
c = lcm(*a_L) -1

#print(c)
ans = 0
for val in a_L:
    ans += c%val
print(ans)

Submission status: Runtime Error

Solution code:
I = int(input())
B = 0
for i in range(I):
	A = input()
	B = A - 1 + B
print(str(B))

Submission status: Runtime Error

Solution code:
I = int(input())
B = 0
for i in range(I):
	A = input()
    B = A - 1 + B
print(str(B))

Submission status: Runtime Error

Solution code:
I = int(input())
B = 0
for i in range(I):
	A = input()
    B = A - 1 + B
print(B)

Submission status: Runtime Error

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

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

p=1
for i in L:
    p=lcm(i,p)
q=0
print(sum([(p-1)%i for i in L]))

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<fstream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	int num;
	for( int i=0; i<n; i++ ) {
		sfd(num);
		sum += num-1;

	}
	cout << sum;
	
	return 0;
}

Submission status: Runtime Error

Solution code:
n = input()
a = input().split()
b = []
for i in a :
    b.append(int(i));
def gcd(i, j) :
    if( j==0 ) :
        return i
    else :
        return gcd(j, i%j)
def F(x) :
    ans = 0
    for i in b :
        ans += x%i
    return ans
c = b[0]*b[1]/gcd(b[0], b[1])
for i in range(2, len(b)) :
    c = c*b[i]/gcd(c, b[i])
d = int(F(c-1))
print(d)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
A=np.array(a)
g=np.gcd.reduce(A)
m=1
for i in range(n):
  m*=a[i]
l=m//g
print(l+1)

Submission status: Runtime Error

Solution code:
import numpy
n=int(input())
a=list(map(int,input().split()))
A=np.array(a)
g=np.gcd.reduce(A)
m=1
for i in range(n):
  m*=a[i]
l=m//g
print(l+1)

Submission status: Runtime Error

Solution code:
import fractions
n=int(input())
a=list(map(int,input().split()))
g=fractions.gcd(*a)
m=1
for i in range(n):
  m*=a[i]
l=m//g
print(l+1)

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()

ans = 0

#最小公倍数
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)

lcm_num = lcm_list(data)

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

print(ans)

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()

ans = 0

#最小公倍数
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)

lcm_num = lcm_list(data)

for i in range(n):
    ans += lcm_num % data[i]

print(ans)

Submission status: Runtime Error

Solution code:
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools
    import fractions
    import functools

    n = int(input())
    as_ = list(map(int, input().split()))
        
    # gcd = functools.reduce(math.gcd, as_)
    gcm = as_[0]
    for i in range(1, n):
        gcm = gcm * as_[i] // math.gcd(gcm, as_[i])
        # print(gcm)
    # print(gcm - 1)
    gcm_1 = gcm - 1
    print(functools.reduce(lambda x, y: x + gcm_1 % y, as_, 0))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# 高橋君！の問題について
# したのコードでTLEになってしまうのは、もうPythonの限界なのか、
# 無駄なプロセスがあるのかどうかを聞く。

H,W=map(int,input().split())
mp=[list(input()) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if mp[i][j]=="s":
            start=(i,j)
        elif mp[i][j]=="g":
            goal=(i,j)
dxy=[(1,0),(0,1),(-1,0),(0,-1)]
import queue
from collections import defaultdict
q=queue.Queue()
d=defaultdict()
q.put(start)
while not q.empty():
    now=q.get()
    if not now in d.keys():
        d[now]=0
    for (dx,dy) in dxy:
        n_0=now[0]+dx
        n_1=now[1]+dy
        #すでに行っていたとしても、塀をより壊していない
        #ルートなら採用するべき
        if (n_0,n_1) in set(d.keys()):
            if mp[n_0][n_1]=="#":
                if d[(n_0,n_1)]>d[now]+1:
                    q.put( (n_0,n_1) )
                    d[(n_0,n_1)]=d[now]+1
            else:
                if d[(n_0,n_1)]>d[now]:
                    q.put( (n_0,n_1) )
                    d[(n_0,n_1)]=d[now]
        else:#初めてのルート
            if 0<=n_0<H and 0<=n_1<W:
                if mp[n_0][n_1]=="g":
                    print("YES")
                    exit(0)
                elif mp[n_0][n_1]=="#":
                    if d[now]<2:
                        q.put( (n_0,n_1) )
                        d[(n_0,n_1)]=d[now]+1
                else:
                    q.put( (n_0,n_1) )
                    d[(n_0,n_1)]=d[now]
print("NO")

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

#aの最小公倍数を求める
lcm_t = a[0]

for j in range(1,N):
    lcm_t = lcm(lcm_t,a[j])

lcm_t = max(1,lcm_t-1)

ans = 0

for k in a:
    ans += lcm_t % k

print(ans)

Submission status: Runtime Error

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

for i in range(n):
  m = fractions.lcm(m, a[i])
m -= 1

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

print(ans)

Submission status: Runtime Error

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

print(sum(s) - n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd


N = int(input())
A = [int(a) for a in input().split()]
def lcm(a,b):
    return (a*b//gcd(a, b))
def lcmm(l):
    return reduce(lcm, l)

m = lcmm(A) - 1
print(sum([m%a for a in A]))

Submission status: Runtime Error

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