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 math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
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)

mod = 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)]
"""

# Lの最小公倍数探索
# mの探索範囲をどのように絞ればいいかが分からない
if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))

    print(sum((x - 1) for x in L))

Submission status: Accepted

Solution code:
import fractions
from functools import reduce

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

m = reduce(lambda x, y:x*y, a_list) - 1
ans = sum([m % a for a in a_list])
print(ans)

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:
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    return sum(A) - len(A)
    
if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = string_to_int(inputs[0])
    count = nums[0]
    for i in range(1, len(nums)):
        count *= nums[i]
    count -= 1
    ret = 0
    for n in nums:
        ret += count % n
    return ret


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
n = int(input())
A = [int(el) for el 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:
if __name__ == '__main__':
    n = int(input())
    a = list(map(int,input().split()))

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

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())
a=list(map(int,input().split()))
import fractions
d=a[0]
for i in range(n-1):
	d=(d*a[i+1])//fractions.gcd(a[i+1],d)
d-=1
ans=0
for i in range(n):
	ans+=d%a[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions
from functools import reduce


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    lcm_a = lcm(*a)
    fm = sum([(lcm_a - 1) % ai for ai in a])
    return fm


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


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


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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


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


# print(lcm(lcm(3,4),6))
N = int(input())
A = [int(_) for _ in input().split()]
tmp = A[0]
for a in A[1:]:
    tmp = lcm(tmp, a)
tmp-=1
ans = 0
for a in A:
    ans +=tmp % a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce

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

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

lcm = reduce(lambda x, y: (x * y) // gcd(x, y), A)

score = 0
for a in A:
    score += (lcm - 1) % a

print(score)

Submission status: Accepted

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

    ans = 0
    for a in A:
        ans += a - 1

    print(ans)
main()

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:
import os, sys, re, math

from functools import reduce
from fractions import gcd
def lcm(vals):
    return reduce((lambda x, y: (x * y) // gcd(x, y)), vals, 1)

lines = sys.stdin.readlines()

n = int(lines[0])
a = [int(k) for k in lines[1].split()]

m = lcm(a) - 1
print (sum([m % k for k in a]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = raw_input()
n = int(line)
line = raw_input()
a = [int(s) for s in line.split(' ')]
print sum(a) - n

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
nums = list(map(int, input().split(' ')))
def gcd(a, b):
   return b if a % b == 0 else gcd(b, a % b)
def lcm(a, b):
   return a * b // gcd(a, b)
lcms = nums[0]
for i in range(1, len(nums)):
    lcms = lcm(lcms, nums[i])

ans = 0
for i in range(len(nums)):
    ans += ((lcms-1) % nums[i])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

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

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

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

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    sum += (l[i] - 1)

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import collections

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n = getint()
a = getints()

res = sum(a) - len(a)
print(res)

Submission status: Accepted

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

print(sum(a_list)- N)

Submission status: Accepted

Solution code:
N = int(input())

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

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

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()))
total=0
for i in range(N):
    total+=A[i]
print(total-N)

Submission status: Accepted

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

INPUT = lambda: sys.stdin.readline().strip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


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


def main():
    N = INT()
    A = LIST()
    f_max = 0
    f_limit = sum(A) - N

    for m in range(lcm(*A)-1, -1, -1):
        f = sum(list(map(lambda a: m % a, A)))

        if f > f_max: f_max = f
        if f_max == f_limit: break

    print(f_max)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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()))
cnt = 0
for i in a:
    cnt += i - 1
print(cnt)

Submission status: Accepted

Solution code:
import fractions

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

ans = nums[0]

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

for i in range(1, N):
    ans = lcm(ans, nums[i])

total = 0

for num in nums:
    total += (ans-1) % num
print(total)

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:
input()
print(sum([int(x)-1 for x in input().split(' ')]))

Submission status: Accepted

Solution code:
N = int(input())
nums = [int(x) for x in input().split()]

print(sum(nums) - N)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
  ans += a[i]
print(ans - len(a))

Submission status: Accepted

Solution code:
from functools import reduce

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 lcm_list(n):
    return reduce(lcm, n)


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

print(sum(a)-n)

Submission status: Accepted

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


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


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

Submission status: Accepted

Solution code:
from fractions import gcd


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


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

cumlcm = A[0]
for a in A[1:]:
    cumlcm = lcm(cumlcm, a)
m = cumlcm - 1
f = sum(map(lambda a: m % a, A))
print(f)

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

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

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



buff = 1

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

Submission status: Accepted

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

max_a = max(a_list)

max_amari = max_a - 1
m = max_a * 2 - 1

amari_list = []
shou_list = []

for a in a_list:
    amari_list.append(a - 1)

ans = sum(amari_list)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

print(sum-N)

Submission status: Accepted

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

answer = 0 
for i in a:
  answer += i - 1

print(answer)

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

print(sum(li) - len(li))

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    a = list(int(_) for _ in input().split())
    cnt = 0
    for i in range(N):
        cnt += a[i] - 1
    print(cnt)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import functools
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
s = 1
for a in A:
    s *= a
s -= 1
ans = 0

for a in A:
    ans += s % a

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ABC103C
import sys

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

sum = 0
for i in range(0,n):
	sum+=hoge[i]
sum -= n
print(sum)

Submission status: Accepted

Solution code:
# 2019/07/24

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

Submission status: Accepted

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

        
print(sum(c)-len(c))

Submission status: Accepted

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

Submission status: Accepted

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

s=0
for i in range(0,n):
    s += a[i]-1
print(s)

Submission status: Accepted

Solution code:
#最大公約数
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

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

#最大公約数（複数）
def gcds(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return gcd(l[0], l[1])
    else:
        n = len(l) // 2
        L = l[:n]
        R = l[n:]
        return gcd(gcds(L), gcds(R))

#最小公倍数(複数)
def lcms(l):
	if len(l) == 1:
		return l[0]
	elif len(l) == 2:
		return lcm(l[0], l[1])
	else:
		n = len(l) // 2
		L = l[:n]
		R = l[n:]
		return lcm(lcms(L), lcms(R))
      
n = int(input())
a = [int(i) for i in input().split()] 

def f(m, l):
  ans = 0
  for i in l:
    ans += m%i
  return ans

print(f(lcms(a)-1, 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:
# ABC103 C-Modulo Summation

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

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

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:
def gcd(a, b):
    c = a % b
    if c == 0:
        return b
    return gcd(b, c)

N = int(input())
a = list(map(int, input().split()))
lcm = a[0]

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

l_m = []
for i in range(n):
    l_m.append(a[i] - 1)
print(sum(l_m))

Submission status: Accepted

Solution code:
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += a[i]

print(int(ans)-int(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


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

print(sum(A)-N)

Submission status: Accepted

Solution code:
N = int(input())

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

print(sum(a))

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
As = list(map(lambda x : int(x) - 1, input().split()))

print(sum(As))

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=l[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  n=I()
  l1=LI()

  l2=[]
  for x in l1:
    _l=getPrimeList(x)
    l2+=summarize_list(_l)

  l2.sort(reverse=True)

  k=1
  a=l2[0]
  for x in l2[1:]:
    # print(x)

    if a[0]!=x[0]:
      k*=a[0]**a[1]
      a=x
      # print(k)

  k*=a[0]**a[1]
  k-=1

  # print(k)

  b=0
  for x in l1:
    b+=k%x

  return b

# main()
print(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())
A = list(map(int, input().split()))

ans = sum(A) - len(A)
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:
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 = [int(x) for x in input().split()]
sum = 0
for i in a:
    sum += i
sum = sum - N
print(sum)

Submission status: Accepted

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

print(sum(a) - N)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
nums = a[0]
for num in a:
    if(nums % num != 0):
        nums *= num
ans = 0
nums -= 1
for i in a:
    ans += nums % i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

N = int(input())
arr = list(map(int, input().split()))
LCM = arr[0]
ctr = 0

for i in range(1, N):
    LCM = lcm(LCM, arr[i])

for j in range(N):
    ctr += (LCM - 1) % arr[j]

print(ctr)

Submission status: Accepted

Solution code:
from fractions import gcd
N = int(input())
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, N):
    lcm = lcm * a[i] // gcd(lcm, a[i])

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

import fractions
from functools import reduce

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

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

y=lcm(x)-1

res=0

for j in range(n):
	res+=y%x[j]

print(res)

Submission status: Accepted

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

pro=1
for i in range(N):
    pro*=a[i]
m=pro-1
f=0
for i in range(N):
    f+=m%a[i]
print(f)

Submission status: Accepted

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

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

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

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

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

num = lcm(*a) - 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd


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


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


n = int(input())
lst_a = list(map(int, input().split()))
l = lcm_list(lst_a)


ans = sum((l-1) % a for a in lst_a)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

lcm = lcm_list(a_lis)

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

Submission status: Accepted

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

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:
# (lcm-1) % Ai なんだけどMLEなりそうな予感

from functools import reduce

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


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


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


x = reduce(lambda x, y: lcm(x, y), arr) - 1

ans = 0
for a in arr:
    ans += x % a
print(ans)

Submission status: Accepted

Solution code:
def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)
n = int(input())
dat_a = list(map(int, input().split()))
res = dat_a[0]
for i in range(n):
    res = lcm(res, dat_a[i])
res -= 1
total = 0
for i in range(n):
    total += res % dat_a[i]
print(total)

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
A = nl()

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

Submission status: Accepted

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

from functools import reduce
from fractions import gcd

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

ans = 0
x = lcmm(a)-1
for i in range(len(a)):
    ans += x % a[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
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())
a = list(map(int,input().split()))
a_adjusted = map(lambda x: x - 1, a)
print(sum(a_adjusted))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())

num_list = [ int(v) for v in input().split() ]
ans = sum(num_list) - n
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

l = reduce(lcm, A)

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

print(ans)

Submission status: Accepted

Solution code:
line = input()
line= input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
for num in num_list:
    ans = ans + (num-1)

print(ans)

Submission status: Accepted

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

res = 1
for a in a_list:
  res *= a

sum = 0
for a in a_list:
  sum += (res-1) % a

print(sum)

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(s) for s in input().split()]
print(sum(a) - N)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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


def f(l, m):
    return sum([m % x for x in l])


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


a = reduce(lcm, A)
print(f(A, a-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import time
import re
import math

def main():
    n=int(input())
    A=list(map(int,input().split()))
    total=0
    m=1
    for a in A:
        m*=a
    m-=1
    for a in range(n):
        mod=A[a]
        total+=m%mod
    print(total)
main()

Submission status: Accepted

Solution code:
N = int(input())
para = [i for i in map(int,input().split())]
"""
(a_1-1)+a_1*x_1 = (a_2-1)+a_2*x_2 = .... = (a_i-1)+a_i*x_i  = .... = (a_n-1)+a_n*x_nの解は存在する
"""
ans = 0 
for i in para :
    ans += i - 1
print(ans)

Submission status: Accepted

Solution code:
import fractions

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

m = 1
for i in range(N):
    m = (a[i] * m) // fractions.gcd(a[i], m)    # 最小公倍数を計算
m -= 1    # m = 最小公倍数 - 1

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
a_s = [int(v) for v in input().split()]
ans = sum([v - 1 for v in a_s])
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import fractions
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]

#ans = sum(data) - N
def lcm(a,b):
    return a * b // fractions.gcd(a,b)

lcm_num = lcm(data[0],data[1])
for i in data[2:]:
    lcm_num = lcm(lcm_num,i)

ans = 0
for j in data:
    ans += (lcm_num-1) % j
print(int(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 = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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