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: Accepted

Solution code:
import fractions 
N = int(input())
a = list(map(int,input().split()))
ans = a[0]
cnt = 0
for i in range(1,N):
    ans = ans * a[i] // fractions.gcd(ans,a[i])
for i in range(N):
    cnt += ((ans-1) % a[i]) 
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

import fractions

# def gcd(x, y):
#     while y != 0:
#         x, y = y, x % y
#     return x
#
# def lcm(x, y):
#     return (x * y) // gcd(x, y)
#
# ans = 1
# for a in A:
#     ans = lcm(ans, a)

ans = sum(A) - len(A)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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 = data[0]


for i in range(1, n):
    ans = ans * data[i] // fractions.gcd(ans, data[i])

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

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:
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
print(np.sum(alist - 1))

Submission status: Accepted

Solution code:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
  
def lcm(a,b):
    return a*b//gcd(a,b)

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

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

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

Submission status: Accepted

Solution code:
n  = int(input())

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

print(sum(L)-n)

Submission status: Accepted

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] // fractions.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: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
S = 1
for i in range(N):
    S *= A[i]
from fractions import gcd
g = 0
for i in range(N):
    g = gcd(g,A[i])
l = S//g
ans = 0
for i in range(N):
    ans += (l-1)%A[i]
print(ans)

Submission status: Accepted

Solution code:
a=int(input(''))
b=input('')


blist = [int(i) for i in b.split(' ')]


dblist = [i-1 for i in blist]

sum = 0
for i in dblist:
    sum+=i

print(sum)

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
lcm=l[0]
def gcd(a,b): 
    if b==0: return a 
    return gcd(b,a%b)
for i in range(1,n):
    lcm=(lcm*l[i])//gcd(lcm,l[i])
m=lcm-1 
print(sum(m%i for i in l))

Submission status: Accepted

Solution code:
import numpy as np
from functools import reduce
from fractions import gcd

N = int(input())
A = np.array(list(map(int, input().split())))
print(A.sum() - N)

Submission status: Accepted

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

print(sum([a-1 for a in As]))

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 a in A:
	ans += (a-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:
n=int(input())
lists=list(map(int,input().split()))
print(sum(lists)-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()))
ans = 0
for ai in a:
   ans+=ai-1
print(ans)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

# lambda式で以降で使えるようにする
ni = lambda: int(ns())
na = lambda: list(map(int, ns().split()))
ns = lambda: stdin.readline()

N = ni()
a = na()

ans = 0
for i in a:
    ans += i-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:



def resolve():
    input()
    print(sum([int(i)-1 for i in input().split()]))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = int(input().strip())
a = [int(str) for str in input().strip().split()]


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

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


b = sorted(list(set(a)))[::-1]
m = b[0]
for i in b[1:]:
    m = lcm(m, i)

m -= 1

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

Submission status: Accepted

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

Submission status: Accepted

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

max = 0
for i in A:
    max += i -1
    
print(max)

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

print(sum(a) - n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum(l)-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = map(int,read().split())
answer = sum(A) - N
print(answer)

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=[int(i) for i in input().split()]
ans=0
for i in range(N):
    ans+=a[i]-1

print(ans)

Submission status: Accepted

Solution code:
#103c
import fractions #math.gcdだとatcoderでは怒られる
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())
a_list = [int(e) for e in input().split()]

n = lcm_list(a_list)-1
#print(n)
#print([n%i for i in a_list])
print(sum([n%i for i in a_list]))

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
count = 0
for i in range(len(a)):
    count +=a[i]
print(count -n)

Submission status: Accepted

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

from fractions import gcd
x = a[0]
for i in range(N-1):
    x = (x * a[i+1]) // gcd(x, a[i+1])

# ans = []
# for i in range(x-10, x+10):
#     r = 0
#     for ai in a:
#         r += i % ai
#     ans.append(r)

# print(ans)


r = 0
for ai in a:
    r += (x - 1) % ai
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

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

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
lcm = lambda x, y : x*y // gcd(x, y)
from functools import reduce
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(input().split())
sum = 0
for i in range(N):
    sum+=int(a[i])-1
print(sum)

Submission status: Accepted

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(lst):
    return reduce(lcm_base, lst, 1)

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

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

Submission status: 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 = [int(i) for i in input().split()]

print(sum(a) - N)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    t = 0
    for i in range(n):
        t += (a[i] - 1)
    print(t)


if __name__ == '__main__':
    slove()

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 fractions import gcd

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

# m = a[i]の最小公倍数-1
lcm = 1
for i in range(n):
    lcm *= a[i] // gcd(lcm, a[i])

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

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

mod = 1
for i in range(len(A)):
    mod = lcm(mod, A[i])
mod -= 1
# print(mod)
ans = 0
for i in range(len(A)):
    ans += mod % A[i]
print(ans)

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split());print(sum(a)-n)

Submission status: Accepted

Solution code:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
N = int(input())
array = list(map(int, input().split()))
t = 1
for i in array:
    t = lcm(t,i)
t -= 1
ans = 0
for k in range(N):
    ans += t % array[k]
print(ans)

Submission status: Accepted

Solution code:
import fractions

def lcm(x,y):
    return (x*y) // fractions.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: Accepted

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

Submission status: Accepted

Solution code:
import sys

# Input
N = int(input())
aaa = list(map(int, sys.stdin.readline().split()))

sum_aaa = sum(aaa)

# Outout
print(sum_aaa - N)

Submission status: Accepted

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

Submission status: Accepted

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 main():
    n = int(input())
    a = list(map(int, input().split()))
    x = 1
    for i in a:
        x = lcm(x, i)
    x -= 1
    ans = 0
    for i in a:
        ans += x % i
    print(ans)


main()

Submission status: Accepted

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

print(sum(aa - 1 for aa in a))

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
l = [int(i) for i in input().split()]

l.sort()

ans = 0

for i in l:
    ans += i-1
    
print(ans)

Submission status: Accepted

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

def gcd(a, b):
  if b > a:
    a, b = b, a
  a, b = b, a % b
  if b == 0:
    return a
  else:
    return gcd(a,b)
def mcd(a, b):
  return a * b // gcd(a, b)

m = a.pop()
while a:
  t = a.pop()
  m = mcd(m, t)

print (sum([(m-1) % i for i in b]))

Submission status: Accepted

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

# f(m)の最大値は、sum(ai-1)である。
# → m=a1*a2*...*aN -1 とすれば良い。

m=1
for a in a_list:
    m*=a
m-=1    

mod_all=0
for a in a_list:
    mod_all+=m%a
print(mod_all)

Submission status: Accepted

Solution code:
from functools import reduce
import fractions

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

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

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

# mの選び方 → 最小公倍数-1
m=lcm_list(a_list)-1

mod_all=0
for a in a_list:
    mod_all+=m%a
print(mod_all)

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:
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math
import fractions
gcd = math.gcd if hasattr(math, "gcd") else fractions.gcd
lcm = lambda x, y: (x * y) // gcd(x, y)

lcm_ufunc = np.frompyfunc(lcm, 2, 1)

N = int(input())
a = np.array([int(i) for i in input().split()])
m = lcm_ufunc.reduce(a) - 1
print(np.mod(m, a).sum())

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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: Accepted

Solution code:
from fractions import gcd

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

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

Submission status: Accepted

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

ans = 0
for i in lst:
  ans += i - 1
print(ans)

Submission status: Accepted

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

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

def lcm(c,d):
    return c*d//gcd(c,d)
l = lcm(li[0],li[1])   
for i in range(2,len(li)):
    l = lcm(l,li[i])

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce


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


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


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

x = lcm_list(A) - 1
print(sum(x % a for a in A))

Submission status: Accepted

Solution code:
from functools import reduce

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

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

times = reduce(lambda x, y: x * y, a)
print(f(times-1))

Submission status: Accepted

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


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


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


def lcm_s(my_list):
    g = lcm(my_list[0], my_list[1])
    for i in range(2, len(my_list)):
        g = lcm(g, my_list[i])
    return g

def f(m, my_list):
  result = 0
  for a_i in my_list:
    result += m % a_i
  return result

print(f(lcm_s(a) - 1, a))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
count = 0
for ai in a:
    count += ai - 1
print(count)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
print(sum(LI()) - n)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
aList = list(map(int,input().split()))
ans = 0
for a in aList:
    ans += (a-1)
print(ans)

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:
print(- int(input()) + sum(map(int, input().split())))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions 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: Accepted

Solution code:
# ABC103C - Modulo Summation
def main():
    # L = LCM(A) -> (L - 1) mod Ai = Ai - 1
    # -> max of f (f(L - 1)) = (A1 - 1) + (A2 - 1) + ... + (An - 1)
    N, *A = map(int, open(0).read().split())
    ans = sum(A) - N
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools

N=int(input())
a=list(map(int,input().split()))
pa=1
for i in a:
  pa*=i
pa-=1
#print(pa)
ans=0
for i in a:
  ans+=pa%i
print(ans)

Submission status: Accepted

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

LCM = a[0]
for i in range(1, n):
    LCM = LCM * a[i] // fractions.gcd(LCM, a[i])

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
ans=sum(A)-len(A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

tmp = lcm(a[0], a[1])
for i in range(2, N):
    tmp = lcm(tmp, a[i])
tmp -= 1
ans = 0
for i in range(N):
    ans += tmp % a[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import fractions
from functools import reduce

n = int(stdin.readline().rstrip())
arg = list(map(int, stdin.readline().rstrip().split()))


def lcm(*numbers):
    return reduce(lambda x, y: (x * y) // fractions.gcd(x, y), numbers, 1)


divided = lcm(*arg) - 1
res = sum(map(lambda x: divided % x, arg))
print(res)

Submission status: Accepted

Solution code:
input()
print(sum(int(tok) - 1 for tok in input().split()))

Submission status: Accepted

Solution code:
from fractions import gcd


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


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

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 = list(map(int, input().split()))
ret = 0
for index in range(n):
    ret += a_list[index] -1
print(ret)

Submission status: Accepted

Solution code:
import math

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

m=1
for i in a:
    m*=i

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

Submission status: Accepted

Solution code:
N, *A = map(int, open(0).read().split())
print(sum(a - 1 for a in A))

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    aaa = list(map(int ,input().split()))
    print(sum([a-1 for a in aaa]))
resolve()

Submission status: Accepted

Solution code:
from functools import reduce
from operator import mul

n = int(input())
a = list(map(int, input().split()))
l = reduce(mul, a) - 1
ans = 0

for i in a:
  ans += l%i

print(ans)

Submission status: Accepted

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

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

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

point=0
count -=1

for i in box:point +=count%i

print(point)

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:
from functools import reduce
from operator import mul
n = int(input())
a = list(map(int, input().split()))

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

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

Submission status: Accepted

Solution code:
# ABC103 C - Modulo Summation
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
t = 0

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

for m in range(N):
    if m == 0:
        t = lcm(A[0],A[1])
    t = lcm(t,A[m])

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

Submission status: Accepted

Solution code:
import numpy as np

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

print(np.sum(a - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
ls=[int(s) for s in input().split()]
ans=0
for x in ls:
  ans+=x-1
print(ans)

Submission status: Accepted

Solution code:
import fractions

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

# 最小公倍数
lcm = a[0]
for i in range(1, N):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
  s += (i-1)
print(s)

Submission status: Accepted

Solution code:
import fractions

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

ans = a[0]
for i in range(1,N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

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

print(cnt)

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

c=1
for i in a:
    c=c*i//fractions.gcd(c,i)

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

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

target = reduce(lcm, L) - 1

print(sum([target % l for l in L]))

Submission status: Accepted

Solution code:
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
Amax = 1
for a in A:
    Amax = Amax*a//gcd(Amax, a)
Amax -= 1
ans = 0
for a in A:
    ans += (Amax % a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
def lcm(x, y):
  return (x * y) // gcd(x, y)
n = int(input())
a = list(map(int, input().split()))
t = reduce(lcm, a, 1) - 1
print(sum(t % a[i] for i in range(n)))

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# 全部の数値の最小公倍数-1が、f(x)のxなのでは？
from fractions import gcd

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

l = 1
for a in A:
    l = lcm(l, a)

l -= 1

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

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
stdin = sys.stdin

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

n = ni()
a_li = na()
list.sort(a_li, reverse=True)
print(sum(a_li) - len(a_li))

Submission status: Accepted

Solution code:
import fractions

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

lcm = a[0]

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

ans = 0

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

Submission status: Accepted

Solution code:
from fractions import gcd


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


N = int(input())
As = list(map(int, input().split()))
ls = [1 for i in range(N + 1)]
for i in range(N):
    ls[i + 1] = lcm(As[i], ls[i])
m = ls[-1] - 1

total = 0
for i in range(N):
    total += m % As[i]
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(max_f)

Submission status: Accepted

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

Submission status: Accepted

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

answer = 0
for a in ai:
    answer = answer + (a - 1)

print(answer)

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
a = III()

print(sum(a)-len(a))

Submission status: Accepted

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

print(s - n)