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-----
3
3 4 6

-----Sample Output-----
10

f(11) = (11\ mod\ 3) + (11\ mod\ 4) + (11\ mod\ 6) = 10 is the maximum value of f.

Difficulty: introductory

Starter code:

Solutions:
N = int(input())
a = list(map(int,input().split()))
aa = []
for i in a:
    aa.append(i-1)
print(sum(aa))

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

ans = 0

for i in a:
  ans += i-1

print(ans)

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

m = lcm_list(a) - 1

f = sum([m % item for item in a])



print(f)



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

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

# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, a):
    print((sum([ai - 1 for ai in a])))


def __starting_point():
    N = int(input())
    a = [int(i) for i in input().split()]
    solve(N, a)

    # # test
    # from random import randint
    # from func import random_str
    # solve()

__starting_point()

# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
print((sum(a) - n))


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

for i in range(N):
    an[i] = an[i] - 1
print(sum(an))

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


import sys
input = sys.stdin.readline # for speed up
#sys.setrecursionlimit(10**9)

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

import math
r=0
for ii in range(1,n):
  r=(r*a[ii])//math.gcd(r,a[ii])

def func(x):
  y=0
  for aa in a:
    y+=x%aa
  return y

print((func(r-1)))


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

def lcm(A):
  x = A[0]
  for i in range(1, len(a)):
    x = (x * A[i]) // gcd(x, A[i])
  return x
 
n = lcm(a) - 1
ans = 0
for v in a:
  ans += n % v
print(ans)

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

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

print(sum(a)-n)

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

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

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

# coding: utf-8


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

def __starting_point():
    main()

__starting_point()

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    a = inl()
    ans = 0
    for x in a:
        ans += x - 1

    return ans


print(solve())


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

i = input;i();print((sum([int(x)-1 for x in i().split()])))


a=int(input())
b=list(map(int,input().split()))
c=sum(b)
print(c-a)

n = int(input())
l = list(map(lambda x: int(x)-1,input().split()))

print(sum(l))

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

print((sum(a)-n))


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

calc = 0

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

print(calc)

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)

from math import gcd
n = int(input())
A = list(map(int, input().split()))

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

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)

import numpy as np
input()
print(sum(np.array(list(map(int,input().split())))-1))

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

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

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

print(sum(a)-n)

'''
Created on 2020/10/01

@author: harurun
'''
import sys
pin=sys.stdin.readline

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

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

def main():
  N=int(pin())
  a=list(map(int,pin().split()))
  s=a[0]
  for i in range(N-1):
    s=lcm(a[i+1],s)
  ans=0
  for i in a:
    ans+=(s-1)%i
  print(ans)
  return
main()

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

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

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

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

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

# 結果出力
print(ans)


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

# -*- 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)

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)

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

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

ans = 0

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

print(ans)

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)

def __starting_point():
    resolve()

__starting_point()

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


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

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

    

def __starting_point():
    main()
__starting_point()

import math
from functools import reduce

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

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

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

lcm = lcm_list(l)

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


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

print(sum(a)-n)

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)

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

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

# -*- 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)


def __starting_point():
    # 標準入力を取得
    N, a = get_input()

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

__starting_point()

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)

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

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

print((S-N))


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

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

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


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


def __starting_point():
    main()

__starting_point()

import math
from functools import reduce


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

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


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

MOD = lcm_list(A)-1

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

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


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

print(ans)

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

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

from math import gcd
from functools import reduce


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


N, *A = list(map(int, open(0).read().split()))
l = reduce(lcm, A) - 1
print((sum(l % a for a in A)))



N=int(input())

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

ans=0

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

print(ans)


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


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

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)
def __starting_point():
    main()
__starting_point()

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

ans=[]
for ai in a:
  ans.append(ai-1)

print(sum(ans))

K = int(input())
a = map(int,input().split())
print(sum(a)-K)

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

print(sum(a) - n)

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

ans = sum(A) - N
print(ans)

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

from math import gcd
from functools import reduce

def lcm(x,y):
    return x*y//gcd(x,y)
    
a = reduce(lcm,L)

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

print(ans)

N = int(input())
S = list(map(int,input().split()))
print(sum(S)-len(S))

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

print(ans)

import fractions
def lcm(a, N):
  ans = a[0]
  for i in range(1, N):
      ans = ans * a[i] // fractions.gcd(ans, a[i])
  return ans
 
def main():
  N = int(input())
  A = list(map(int,input().split()))
  num = lcm(A, N) - 1
  answer = 0
  for i in A:
    answer += num % i
  print(answer)

def __starting_point():
    main()
__starting_point()

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

n,a=open(0);print(sum(map(int,a.split()))-int(n))

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

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

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

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

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

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

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

print(ans)


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

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

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

def __starting_point():
    main()

__starting_point()

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

print(sum(a)-n)

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

print(sum(ans)-n)

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

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

ans = 0

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

print(ans)

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



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

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

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


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)

from math import gcd
n = int(input())
a = list(map(int, input().split()))

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

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

import math
from functools import reduce

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

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

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

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

import math

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

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

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

print(ans)

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

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

def main():
    n=int(input())
    a=list(map(int,input().split()))
    print(sum(a)-n)
def __starting_point():
    main()
__starting_point()

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

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

print(ans)

n=int(input())
a=map(int,input().split())
b=[]
for i in a:
    b.append(i-1)
print(sum(b))

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)


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

#print(li)

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

print(ans-n)

def main():
    n = int(input())
    a_lst = list(map(int, input().split()))
    maximum = sum(a_lst) - n
    
    print(maximum)
    

def __starting_point():
    main()
__starting_point()

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


n = int(input())
lis = list(map(int, input().split()))
ans = 0

for i in lis:
  ans += i-1

print(ans)


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