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: Time Limit Exceeded

Solution code:
import fractions

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

lcm = a[0]
for i in a:
    lcm = lcm * i / fractions.gcd(lcm, i)

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

Submission status: Time Limit Exceeded

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

def gcd(x,y):#ユークリッドの互除法
  if y > x:
    x, y = y, x
  while y != 0:
    x, y = y, x % y
    if y == 0:
      return x
    
def lcm(x,y):
  return x * y / gcd(x,y)

m = 1
for i in range(N):
  m = lcm(m, A[i])
  
count = 0
for i in range(N):
  count += (m - 1) % A[i]
  
print(int(count))

Submission status: Time Limit Exceeded

Solution code:
def gcd(a, b):
    if(a < b):
        a, b = b, a

    while b:
        a, b = b, a % b
    return a

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

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

Submission status: Time Limit Exceeded

Solution code:
#ABC 103
#最小公倍数
from functools import reduce

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

#a,bの最小公倍数
def lcm_base(a, b):
    return a * b // gcd (a, b)
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: Time Limit Exceeded

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)

n=int(input())
l=list(map(int,input().split()))
a=lcm_list(l)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


N = II()
a = LI()
# aのすべての数の最小公倍数-1をaの各要素で割った剰余の和
print(sum([(LCM_LIST(a) - 1) % i for i in a]))

Submission status: Time Limit Exceeded

Solution code:
import fractions
from functools import reduce

def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)
def lcm_list(l):
    return reduce(lcm, l, 1)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 8 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    print(f)
    ans.append(f)
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 9 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    print(f)
    ans.append(f)
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def piyo():
    _ = int(input())
    b = np.array(list(int(i) for i in input().split()),dtype=int)
    fuga = []
    piyopiyo = []
    for hoge in range(10 ** 5):
        for hogehoge in b:
            piyopiyo.append((hoge+1)%hogehoge)
        fuga.append(np.sum(piyopiyo))
        piyopiyo.clear()
    print(max(fuga))
        
if __name__ == '__main__':
    piyo()

Submission status: Time Limit Exceeded

Solution code:
def f(m):
    ans = 0
    for a in aList:
        ans += m % a
    return ans

def check_finish(can):
    for a in aList:
        if(can % a != 0):
            return False
    return True
  
  
N = int(input().strip())
aList = list(map(int, input().strip().split(" ")))

count = 1
ans = 0
while(True):
    tmp_ans = f(count)
    ans = max(tmp_ans, ans)
    if(check_finish(count)):
        break
    count += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
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: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
b =[int(i) for i in a]
if n == len(b):
    max_value = max(b)
    print(max([sum([(i - 1) % j for j in b]) for i in range(max_value)]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
b =[]
for i in a:
    b.append(int(i))
ans = []
if n == len(b):
    max_value = max(b)
    for i in range(max_value):
        tmp = 0
        for j in b:
            tmp += (i - 1) % j
        ans.append(tmp)
    print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
b =[]
for i in a:
    b.append(int(i))
ans = []
if n == len(b):
    max_value = max(b)
    for i in range(max_value*2):
        tmp = 0
        for j in b:
            tmp += (i - 1) % j
        ans.append(tmp)
    print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = input().split()
b =[]
for i in a:
    b.append(int(i))
ans = []
if n == len(b):
    max_value = max(b)
    for i in range(max_value*3 ):
        tmp = 0
        for j in b:
            tmp += (i - 1) % j
        ans.append(tmp)
    print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
# 最大公約数を求める関数
def gcd(a,b):
    rem = a % b
    while rem != 0:
        a = b
        b = rem
        rem = a % b
    return b

# 最小公倍数を求める関数
def lcm(a,b):
    return (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: Time Limit Exceeded

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

product=1
for i in range(len(a)):
    product*=a[i]


mods=[]
for i in range(product):
    mods.append(sum([i%a_l for a_l in a]))

ans=max(mods)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
from functools import reduce
def lcm(a,b): return abs(a * b)/gcd(a,b) if a and b else 0

n = input()

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

mlcm = 1
for x in set(xs):
  mlcm = lcm(mlcm, x)

mlcm -= 1
mlcm = int(mlcm)
print(sum([ mlcm%x for x in xs]))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
def lcm(a,b): return abs(a * b)/gcd(a,b) if a and b else 0

n = input()

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

from functools import reduce

mlcm = int(reduce(lcm, xs))

mlcm -= 1
print(sum([ mlcm%x for x in xs]))

Submission status: Time Limit Exceeded

Solution code:
import math


class Sieve:
    """Sieve of Eratosthenes.

    List primes up to n.
    """

    def __init__(self, n):
        self.__prime = []
        self.__is_prime = [i >= 2 for i in range(n + 1)]

        for i in range(2, int(math.sqrt(n)) + 1):
            if self.__is_prime[i]:
                for j in range(i * i, n + 1, i):
                    self.__is_prime[j] = False

        for i in range(2, n + 1):
            if self.__is_prime[i]:
                self.__prime.append(i)

    def prime(self):
        return self.__prime

    def is_prime(self, n):
        return self.__is_prime[n]


if __name__ == '__main__':
    N = int(input())  # 2 <= N <= 3000
    a = list(map(int, input().split()))  # 2 <= ai <= 100000
    b = [ai for ai in a]

    p = Sieve(100000).prime()  # len = 9952

    prime_to_power = [0 for _ in range(p[-1] + 1)]
    for i in range(len(a)):
        for prime in p:
            power = 0
            while b[i] % prime == 0:
                b[i] /= prime
                power += 1
            prime_to_power[prime] = max(prime_to_power[prime], power)
            if b[i] == 1:
                break

    lcm = 1
    for i in range(len(prime_to_power)):
        lcm *= i ** prime_to_power[i]
    m = lcm - 1
    ans = 0
    for ai in a:
        ans += m % ai
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math


class Sieve:
    """Sieve of Eratosthenes.

    List primes up to n.
    """

    def __init__(self, n):
        self.__prime = []
        self.__is_prime = [i >= 2 for i in range(n + 1)]

        for i in range(2, int(math.sqrt(n)) + 1):
            if self.__is_prime[i]:
                for j in range(i * i, n + 1, i):
                    self.__is_prime[j] = False

        for i in range(2, n + 1):
            if self.__is_prime[i]:
                self.__prime.append(i)

    def prime(self):
        return self.__prime

    def is_prime(self, n):
        return self.__is_prime[n]


if __name__ == '__main__':
    N = int(input())  # 2 <= N <= 3000
    a = list(map(int, input().split()))  # 2 <= ai <= 100000
    b = [ai for ai in a]

    p = Sieve(100000).prime()  # len = 9952

    prime_to_power = [0 for _ in range(p[-1] + 1)]
    for i in range(len(a)):
        for prime in p:
            power = 0
            while b[i] % prime == 0:
                b[i] /= prime
                power += 1
            prime_to_power[prime] = max(prime_to_power[prime], power)

    lcm = 1
    for i in range(len(prime_to_power)):
        lcm *= i ** prime_to_power[i]
    m = lcm - 1
    ans = 0
    for ai in a:
        ans += m % ai
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce


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


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


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


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

mod = []
for m in range(lcm(a)):
    k = [m % a[i] for i in range(N)]
    mod.append(sum(k))
print(max(mod))

Submission status: Time Limit Exceeded

Solution code:
c=0
for i in range(100000000000):
    c+=1

Submission status: Time Limit Exceeded

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

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

def f(m, input):
  r = 0
  for i in input:
    r += m % i
  return r

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

max = 0
for x in a_n:
  max += x
 
result = []
for m in range(max):
  out = f(m, a_n)
  result.append(out)
re = sorted(result)
#print(re[-1])
#print(max) #994 518 941 851 647 2 581 -> 4534
print(max - len(a_n))

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans_list = []
ann = []
ana = 1
for j in range(N):
    ana = ana * int(a[j])
ana = ana -1
for i in range(N):

    ans = 0
    for k in range(i+1):
        ans += int(ana % int(a[k]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans_list = []
ann = []
for i in range(N):
    ana = 1
    ans = 0
    for j in range(i+1):
        ana = ana * int(a[j])
    ana = ana -1
    for k in range(i+1):
        ans += int(ana % int(a[k]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans_list = []
ann = []
for i in range(N):
    ana = 1
    ans = 0
    for j in range(i+1):
        ana = ana * int(a[j])
    ana = ana -1
    for k in range(N):
        ans += int(ana % int(a[k]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Time Limit Exceeded

Solution code:
import math

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

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for i in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Time Limit Exceeded

Solution code:
#encoding utf:8

n = int(input())
# num=[]
num = list(int(i) for i in input().split())
# for i in range(n):
#     num.append(int(input().split()))

#gcd 最大公約数
def gcd(a,b):
    gcd = 1
    list_a = []
    list_b = []
    for i in range(a):
        if a % (i+1) ==0:
            a = a/(i+1)
            list_a.append(i+1)
    for i in range(b):
        if b % (i+1) ==0:
            b = b/(i+1)
            list_b.append(i+1)
    # print(list_a,list_b)
    for num in range(len(list_a)):
        if list_a[num] in list_b:
            gcd = gcd * list_a[num]
    return int(gcd)

# lcm: 最小公倍数
def lcm(a,b):
    lcm = a*b/gcd(a,b)
    return int(lcm)

for i in range(n):
    if i == 0:
        a_lcm = lcm(num[0], num[1])
    a_lcm = lcm(a_lcm,num[i])

max = a_lcm-1
f=0
for i in range(len(num)):

    f += (max%num[i])
print(f)

Submission status: Time Limit Exceeded

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

max = 0
i = lim
while i != 0:
  result = sum([i % j for j in ar])
  if result > max:
    max = result
  i -= 1
    
print(max)

Submission status: Time Limit Exceeded

Solution code:
def lcm(a, b):
    if b > a :
        tmp = a
        a = b
        b = tmp

    x = a * b
    r = a % b
    while (r != 0) :
        a = b
        b = r
        r = a % b

    return x / b

ans = 0;
n = int(input())
a = [];

string = input()
a = string.split(" ")

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

m = m - 1;

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

print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = input().split()
a = [int(i) for i in a]
res_list = []
for i in range(10 ** 10):
    res = 0
    if i >= 2 and i% 2 == 0:
        if res_list[:i//2] == res_list[i//2:]:
            break
    for j in a:
        res += i % j
    res_list.append(res)
    
print(max(res_list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if st == max:
        sum = st
        break
    ind = np.where(a - n%a == 1)[0]
    c = a[ind]
    n += np.prod(c)
print (sum)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8

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

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

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

def func(x, A):
    ans = 0
    for y in A:
        ans += x%y
    return ans

def hoge(A):
    B = []
    for i in range(len(A)-1):
        for j in range(len(A)-i-1):
            tmp = lcm(A[i], A[i+1+j])
            if tmp not in B: B.append(tmp)
    return B

max_lcm = 0
B = []
for i in range(n-1):
    for j in range(n-i-1):
        tmp = lcm(A[i], A[i+1+j])
        if tmp not in B: B.append(tmp)

while(len(B) > 1):
    B = hoge(B)

print(func(B[0]-1, A))

Submission status: Time Limit Exceeded

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

ans = 0
li_ans = []

primeN = []
tmp = 2
for i in range(2, 100000):
    if primeN:
        for j in range(len(primeN)):
            if i % primeN[j] == 0:
                break
            else:
                if j == len(primeN) - 1:
                    primeN.append(i)
    else:
        if 100000 > tmp:
            primeN.append(i)

for i in primeN:
    for num in a:
        ans += i % num
    else:
        li_ans.append(ans)
        ans = 0
else:
    print(max(li_ans))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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

koubai = 1
for i in range(N):
    koubai = lcm(koubai, a[i])

f = [0 for i in range(koubai)]

for i in range(len(f)):
    for j in range(N):
        f[i] += i % a[j]

print(max(f))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

def gcd(x, y):
 
    if x > y:
        small = y
    else:
        small = x
    for i in range(1, small+1):
        if((x % i == 0) and (y % i == 0)):
            gcd = i
             
    return gcd
 
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

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

    
def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    v = lcm(*a) -1
    ans = sum(v % x for x in a)
    print(ans)
    
        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
tt = list(map(int,input().split()))
    
ss = 1

for i in tt:
    p = []
    p.append(int(ss))
    p.append(int(i))
    q = list(sorted(p))
    while q[1] % q[0] != 0:
        r = [q[1] % q[0] , q[0]]
        s = list(sorted(r))
        q[0] = int(s[0])
        q[1] = int(s[1])

        
    ss = int(ss * i) // q[0]
num = ss
kouho = 0
for num in range(1,num + 1):
    onesum = 0
    for onenum in tt:
        onesum += num % onenum
    if kouho < onesum:
        kouho = onesum
print(kouho)

Submission status: Accepted

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

print(sum(a)-N)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    numbers=[]
    n = int(input())
    numbers=np.array(list(map(int,input().split())))

    print((numbers-1).sum())

    

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = LI()
    ans = 0
    for i in L:
        ans += i-1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    N = int(input())
    ans = sum(list(map(int, input().split()))) - N
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    a = list(map(int, input().split()))

    return N, a


def main(N: int, a: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 正整数の数(2 <= N <= 3000)
        a (list): 正整数(2 <= a_i <= 10^5)
    """
    # 求解処理
    ans = sum(a) - N

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, a = get_input()

    # メイン処理
    main(N, a)

Submission status: Accepted

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

Submission status: Accepted

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

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

s=0
for i in range(N):
  s+=a[i]

print(s-N)

Submission status: Accepted

Solution code:
# モジュールのインポート
import fractions

# 標準入力を取得
N = int(input())
a = list(map(int, input().split()))

# 求解処理
ans = sum(a) - N

# 結果出力
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import heapq


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


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


    print(sum(A)-N)

if __name__ == "__main__":
    main()

# \n

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]

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

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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)

ans = 0
lcm = lcm(*A)

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

Submission status: Accepted

Solution code:
N,*A = map(int,open(0).read().split())

m =1
ans = 0
for a in A:
  m *=a
m-=1

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

Submission status: Accepted

Solution code:
N,*A = map(int,open(0).read().split())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(A)-len(A))

Submission status: Accepted

Solution code:
import fractions

N = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(1,N):
  l = l * a[i] // fractions.gcd(l, a[i])
m = l-1
fm = 0
for i in range(N):
  fm += m % a[i]
print(fm)

Submission status: Accepted

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

#print(n, li)

ans=0
for i in li:
    ans+=i-1

print(ans)

Submission status: Accepted

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

print(sum(a)-n)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 10:04:50 2020

@author: liang
"""
N = int(input())
A = [int(x)-1 for x in input().split()]
ans = sum(A)
print(ans)

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    a = i_list()
    ans = 0
    for i in a:
        ans += i-1
    print(ans)


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

Submission status: Accepted

Solution code:
N=int(input())

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

ans=0

for i in range(N):
    ans+=a[i]-1

print(ans)

Submission status: Accepted

Solution code:
import math

N=int(input())
a=list(map(int,input().split()))
lcm=1
for i in range(N):
    lcm=lcm*a[i]//math.gcd(a[i],lcm)

print(sum((lcm-1)%a[i] for i in range(N)))

Submission status: Accepted

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

print(sum(a)-n)

Submission status: Accepted

Solution code:
def solve():
    _ = int(input())
    A = [int(i) for i in input().split()]
    ans = sum([a - 1 for a in A])
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = input().rstrip()
    a_list = [int(x) for x in input().rstrip().split(" ")]

    print(sum(a_list) - len(a_list))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# 最小公倍数(mathは3.5以降) 
 #参考　https://note.nkmk.me/python-gcd-lcm/
from functools import reduce
import math #(2020-0405  fractions→math)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers): # a,b,cなど
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers): #リスト
    return reduce(lcm_base, numbers, 1)


# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import math

def main():
    N = int(input())
    A = list(map(int, input().split()))
    lcm = 1
    for a in A:
        lcm = lcm * a // math.gcd(lcm, a)
    m = lcm - 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

prod = a[0]
lcm = a[0]
for i in range(1,N):
    x = math.gcd(lcm, a[i])
    lcm = (lcm*a[i])//x

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

Submission status: Accepted

Solution code:
import math
from functools import reduce

n = int(input())
a_list = map(int, input().split())
result = 0
for a in a_list:
    result += a - 1 

print(result)

Submission status: Accepted

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

calc = 0

for i in range(N):
    calc += a[i]-1

print(calc)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(N):
  ans += a[i]-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()

    ans = sum([i - 1 for i in a])
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

ans = 0

for i in range(N):
    ans += A[i]-1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd


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


N = int(input())
A = list(map(int, input().split()))
X = A[0]

for a in A[1:]:
    X = lcm(X, a)
X -= 1
ans = 0
for a in A:
    ans += X % a
print(ans)

Submission status: Accepted

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

# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
  if val1 % val2 == 0:
    ans = a[0]*a[1]//val2
    break
  else:
    tmp = val2
    val2 = val1 % val2
    val1 = tmp

for i in range(2, N):
  val1, val2 = ans, a[i]
  while 1:
    if val1 % val2 == 0:
      ans *= a[i]//val2
      break
    else:
      tmp = val2
      val2 = val1 % val2
      val1 = tmp

f_ans = 0
for i in range(N):
  f_ans += (ans-1)%a[i]
print(int(f_ans))

Submission status: Accepted

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

A = list(map(lambda x: int(math.copysign(x-1, x)), A))

print(sum(A))

Submission status: Accepted

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

ans = 0
for i in range(N):
  ans += A[i] - 1
  
print(ans)

Submission status: Accepted

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

for i in range(1,n):
	m *= a[i]

for i in range(n):
	answer += (m-1) % a[i]

print(answer)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    print(sum(a_list) - n)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(S-N)

Submission status: Accepted

Solution code:
import math

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