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 functools import reduce
import math

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))

    lcm_a = int(reduce(lcm, a_s))

    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Runtime Error

Solution code:
from functools import reduce

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))

    lcm_a = int(reduce(lcm, a_s))

    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Runtime Error

Solution code:
class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))

    lcm_a = a_s.copy()
    while len(lcm_a) > 1:
        a = lcm_a.pop()
        b = lcm_a.pop()
        lcm_a.append(lcm(a, b))
    lcm_a = lcm_a[0]

    # gcd_a = int(reduce(steins_gcd, a_s))
    # lcm_a = int(reduce(lcm, a_s))

    # fm = 0
    # for a in a_s:
    #     fm += (lcm_a-1) % a
    # print(fm)

Submission status: Runtime Error

Solution code:
class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))

    lcm_a = a_s.copy()
    while len(lcm_a) > 1:
        a = lcm_a.pop()
        b = lcm_a.pop()
        lcm_a.append(lcm(a, b))
    lcm_a = lcm_a[0]

    # gcd_a = int(reduce(steins_gcd, a_s))
    # lcm_a = int(reduce(lcm, a_s))
    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Runtime Error

Solution code:
from multiprocessing import Pool
from functools import reduce
from math import ceil

class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))

    lcm_a = a_s.copy()
    while len(lcm_a) > 1:
        a = lcm_a.pop()
        b = lcm_a.pop()
        lcm_a.append(lcm(a, b))
    lcm_a = lcm_a[0]

    # gcd_a = int(reduce(steins_gcd, a_s))
    # lcm_a = int(reduce(lcm, a_s))
    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Runtime Error

Solution code:
from multiprocessing import Pool
from functools import reduce
from math import ceil

class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))
    gcd_a = int(reduce(steins_gcd, a_s))
    lcm_a = int(reduce(lcm, a_s))
    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Runtime Error

Solution code:
from multiprocessing import Pool
from functools import reduce
from math import ceil

class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return (a << k) 


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))
    gcd_a = int(reduce(steins_gcd, a_s))
    lcm_a = int(reduce(lcm, a_s))
    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Runtime Error

Solution code:
from multiprocessing import Pool
from functools import reduce
from math import ceil

class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return (a << k) 


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

if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))
    gcd_a = int(reduce(steins_gcd, a_s))
    lcm_a = int(reduce(lcm, a_s))
    def mod(x):
        return (lcm_a-1) % x
    fm = sum(map(mod, a_s))
    print(fm)

Submission status: Runtime Error

Solution code:
from multiprocessing import Pool
from functools import reduce
from math import ceil

class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

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


if __name__ == "__main__":
    n = int(input())
    a_s = list(map(int, input().split(" ")))
    gcd_a = int(reduce(gcd, a_s))
    lcm_a = int(reduce(lcm, a_s))
    def mod(x):
        return (lcm_a-1) % x
    fm = sum(map(mod, a_s))
    print(fm)

Submission status: Runtime Error

Solution code:
n=int(input())
L=[list(map(int, input().split())) for i in range(D)]
print(sum(L)-n)

Submission status: Runtime Error

Solution code:
import math

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

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

l = 1
for a in A:
  l = lcm(a, l)
B = [(l - 1) % a for a in A]
print(sum(B))

Submission status: Runtime Error

Solution code:
a = ai()
x = lma()
print(sum(x)-a)

Submission status: Runtime Error

Solution code:
import math

N = int(input().strip())
ar = list(map(int,input().strip().split()))

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

koubai = 1

for i in range(0,len(ar)):
    koubai = lcm(ar[i],koubai)

res = 0
koubai -= 1
for i in range(0,len(ar)):
    res += koubai % ar[i]
print(res)

Submission status: Runtime Error

Solution code:
n = int(input())
a = (int(i) for i in input().split())
print(sum(a)-len(a))

Submission status: Runtime Error

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

# print(-(-(n-1)//(k-1)))
print((n+1 + (k - 2)) // (k-1))

Submission status: Runtime Error

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

# print(-(-(n-1)//(k-1)))
print((n + (k - 1)) // k)

Submission status: Runtime Error

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

# print(-(-(n-1)//(k-1)))
print((n + (k - 1)) / k)

Submission status: Runtime Error

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

# print(-(-(n-1)//(k-1)))
print((n + (k - 1)) / k

Submission status: Runtime Error

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


def calcMod(a, m):
  return sum([m % v for v in a])


def mul(a, b):
  return a*b


#print(calcMod(a, reduce(mul, a)-1))
print(sum(a)-N)

Submission status: Runtime Error

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


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


def calcMod(a, m):
  return sum([m % v for v in a])


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


def lcm_list(l):
  g = reduce(lcm, l)
  return g


print(calcMod(a, (int)(lcm_list(a)-1)))

Submission status: Runtime Error

Solution code:
from math import *

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

n = int(input())
a = input().split()

for i in range(n):
    a[i] = int(a[i])

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

l -= 1
s = 0

for i in range(n):
    s += l % a[i]

print(s)

Submission status: Runtime Error

Solution code:

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

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

Submission status: Runtime Error

Solution code:
import math


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


def f(n, A):
    return sum([n % x for x in A])


def main():
    N = int(input())
    A = list(map(int, input().split()))
    retval = 1
    for a in A:
        retval = lcm(a, retval)
    print(f(retval - 1, A))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

# 最小公倍数を求める関数
def lcm(a,b):
    return int((a*b)/gcd(a,b))

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


m = lcm(a[0],a[1])
for i in range(1,len(a)):
    m = lcm(m,a[i])

res = int(sum([(m-1) % e for e in a]))
print(res)

Submission status: Runtime Error

Solution code:
from math import gcd

# 最小公倍数を求める関数
def lcm(a,b):
    return int((a*b)/gcd(a,b))

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


m = lcm(a[0],a[1])
for i in range(1,len(a)):
    m = lcm(m,a[i])

res = int(sum([(m-1) % e for e in a]))
print(res)

Submission status: Runtime Error

Solution code:
import fractions
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())
numbers=list(map(int,input().split()))
m=lcm(*numbers)-1
ans=0
for i in range(n):
    ans+=m%numbers[i]
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = min(3000,reduce(gcd,_ for _ in a))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = min(3000,gcd(_ for _ in a))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = min(3000,gcd(a[i] for i in range(n)))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))

Submission status: Runtime Error

Solution code:
# Modulo Summation
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()))
m = reduce(lcm, a, 1) - 1
print(sum(map(lambda x: m % x, a)))

Submission status: Runtime Error

Solution code:
n=input()
A=list(map(int,input.split()))
t=sum(A)-1
ans=0
for a in A:
    ans += t % a
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
def lcm(x,y):
  return int(x*y/gcd(x,y))
n=int(input())
a=list(map(int,input().split()))
for i in range(1,len(a)):
  if i==1:g=lcm(a[0],a[1])
  else:g=lcm(g,a[i])
c=0
for j in range(len(a)):
  c+=(g-1)%a[j]
print(c)

Submission status: Runtime Error

Solution code:
7
994 518 941 851 647 2 581

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a  = input()
 
ans = 0
a = [int(i) for i in input().split()]
 
for num in a:
  ans += num - 1
  
 print(ans)

Submission status: Runtime Error

Solution code:
input()

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

for num in a:
  ans += num - 1
  
 print(ans)

Submission status: Runtime Error

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

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

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

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

res = 0

for i in range(N):
  res += (alcm-1) % a[i]

print(int(res))

Submission status: Runtime Error

Solution code:
from functools import reduce

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

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

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

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

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

print(int(f))

Submission status: Runtime Error

Solution code:
from functools import reduce

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

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

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

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

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

print(int(f))

Submission status: Runtime Error

Solution code:
from functools import reduce

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

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

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

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

f = 0
m = lcm(a) - 1
for i in a:
  f += m % i

print(int(f))

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

max_iter = lcm(a_list)
# print(max_iter)

max_val = -1

for i in range(max_iter + 1):
    # print("===============")
    # print("Max val = {}, i = {}".format(max_val, i))
    val = sum([i % a for a in a_list])
    max_val = max(max_val, val)

print(max_val)

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

max_iter = lcm(a_list)
# print(max_iter)

max_val = -1

for i in range(max_iter + 1):
    # print("===============")
    # print("Max val = {}, i = {}".format(max_val, i))
    val = sum([i % a for a in a_list])
    max_val = max(max_val, val)

print(max_val)

Submission status: Runtime Error

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

print(sum(A) - N)

Submission status: Runtime Error

Solution code:
import numpy as np
from copy import copy

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

# 1 <= N  <= 10000  O(N^2)
# 1 <= ai <= 10^9   O(ai)

def divider(n, p):
    # Return the number of p in n
    k = 0
    while n % p == 0:
        n = n / p
        k += 1
    return k

ks = []

for a in A:
    k = divier(a, 2)
    ks.append(k)

print(sum(ks))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


N = int(input())

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

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

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

for i in range(len(a)):
    ans += (lcm_list(a) - 1) % a[i]
    
print(ans)

Submission status: Runtime Error

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

def lcm(l):
    def aux(l, i):
        if i == len(l) - 1:
            return l[-1]
        rest = aux(l, i+1)
        return l[i] * rest // gcd(l[i], rest)
    return aux(l, 0)

def modsum(a):
    k = lcm(a) - 1
    return sum(map(lambda x: k % x, a))

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

Submission status: Runtime Error

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

def lcm(l):
    def aux(l, i):
        if i == len(l) - 1:
            return l[-1]
        rest = aux(l, i+1)
        return int((l[i] * rest) / gcd(l[i], rest))
    return aux(l, 0)

def modsum(a):
    k = lcm(a) - 1
    return sum(map(lambda x: k % x, a))

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

Submission status: Runtime Error

Solution code:
import math

def main(N, a):
    m = getlcm(N, a) - 1
    f = 0
    for i in range(N):
        f += m % a[i]
    print(f)

def getlcm(N, a):
    l = 1
    for i in range(N):
        l = l * a[i] // math.gcd(l, a[i])
    return l
    
if __name__ == '__main__':
    N = int(input())
    a = [int(i) for i in input().split()]

    main(N, a)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

input()
l = list(map(int, input().split()))
m = reduce(lcm, l, 1) - 1

ans = 0
for i in range(len(l)):
	ans += m % l[i]

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

input()
l = list(map(int, input().split()))
m = np.lcm.reduce(l) - 1

ans = 0
for i in range(len(l)):
	ans += m % l[i]

print(ans)

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 a / gcd(a, b) * b

n = int(input())
l = 1
a = list(map(int, input().split()))
for i in range(n):
  l = lcm(l, a[i])

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

print(int(sum_))

Submission status: Runtime Error

Solution code:
import math

input()

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

def lcm(a,b):
	return a*b//math.gcd(a,b)
	
N=nums[0]
for i in range(1,len(nums)):
	N=lcm(N,nums[i])

M=0
for i in range(1,N+1):
	cnt=0
	tmp = sum([i%num for num in nums])
	if M < tmp:
		M=tmp
		

print(M)

Submission status: Runtime Error

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

print(sum(list_int)-number_int)

Submission status: Runtime Error

Solution code:
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma:
  i += 1
  if i == N:
    Mb = 0
    B = B[:i]
  else:
    Mb = B[i]
H -= sum(B)
print(i+int(-(-H//Ma)))

Submission status: Runtime Error

Solution code:
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
C = 0
i = 0
while i < len(B) and B[i] > Ma:
  i += 1
H -= sum(B[:i])
print(i+int(-(-H//Ma)))

Submission status: Runtime Error

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

import functools
import fractions

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

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

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

print(answer)
~

Submission status: Runtime Error

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

import functools
import fractions 

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

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / fractions.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 functools

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

def gcd(a, b):
    while b != 0:
        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 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 functools

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

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

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

print(answer)

Submission status: Runtime Error

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

import functools

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

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

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 if a > 0 else 1

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)