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:
n = int(input())
a = list(map(int, input().split()))
ans = 0
m = 1

for i in range(n):
    m = 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()))
print(sum(a) - N)

Submission status: Accepted

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

    print(sum(a) - n)

if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import fractions


def solve(N: int, a: "List[int]"):
    ans = sum(a) - N
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
k=0
m=lcm_list(a)-1
for i in range(n):
    k+=m%a[i]
print(k)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

n = int(input())
a = 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)
  
ans = lcm_list(a) - 1
print(sum([ans % ai for ai in a]))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from fractions import gcd

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

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

    l = lcm_base(A[0], A[1])
    for a in A[2:]:
        l = lcm_base(l, a)
    
    l -= 1
    print(sum([l % a for a in A]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def myAnswer(N:int,A:list) -> int:
   return sum(A) - N

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
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=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=[int(j) for j in input().split()]

ans=0

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

Submission status: Accepted

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

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

a = reduce(lcm,l,1)-1
f = 0
for i in l:
  f += a%i
print(f)

Submission status: Accepted

Solution code:
import fractions
n = int(input())
A = list(map(int,input().rstrip().split(' ')))
def lcm(a,b):
  return int(a*b//fractions.gcd(a,b))
L=1
for x in A:
  L=lcm(L,x)
L-=1
ans=0
for x in A:
  ans+=L%x
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())
amin1 = [int(x) - 1 for x in input().split()]
print(sum(amin1))

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
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])
check=0
for i in range(n):
  check+=(ans-1)%a[i]
print(check)

Submission status: Accepted

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

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

res = 0
tmp = reduce(lcm,a)-1
for i in a:
    res += tmp % i
print(res)

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(0, n):
    ans += a[i] - 1
print(ans)

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
from fractions import gcd
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

lcm = a[0]
ans = 0
for num in a[1:]:
    lcm = lcm * num // gcd(lcm, num)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func(a):
  return int(a) - 1
n = int(input())
alist = list(map(func,input().split()))
print(sum(alist))

Submission status: Accepted

Solution code:
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    print(sum(a) - n)

if __name__ ==  '__main__':
    main()

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:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    print(sum(A) - len(A))



if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from itertools import accumulate as acc
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 = II()
    aa = MII()
    ll = list(acc(aa, lcm))
    lv = ll[-1]-1
    sumv = 0
    for a in aa:
        sumv += lv%a
    print(sumv)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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 a in A:
    ans += a - 1
print(ans)

Submission status: Accepted

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

answer = A[0]
Sum = 0

def gcd(A,B):
    if(B == 0):
        return A
    else:
        return gcd(B, A%B)

#最小公倍数-1がfに入る数なはず
for i in range(1, N):
    answer = answer * A[i] // gcd(answer, A[i])
    
for i in range(N):
    Sum += (answer-1) % A[i]

print(Sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

import fractions

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

mn = 0

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

print(mn)

Submission status: Accepted

Solution code:
f_max = int(input()) * -1

for x in input().split():
    f_max+=int(x) 


print(f_max)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(sum(L)-n)

Submission status: Accepted

Solution code:

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)

def main():
  n = int(readline())
  a = list(map(int, readline().split()))
  k = reduce(lcm, a) - 1
  ans = 0
  for i in range(n):
    ans += k % a[i]
  print(ans)
  
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

def lcm(x,y):
    return x*y//gcd(x,y)
ans=1
for num in a:
    ans=lcm(ans,num)
    
ans-=1

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

Submission status: Accepted

Solution code:
import fractions

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

lcm=1
for a in alist:
  lcm=lcm*a//fractions.gcd(lcm,a)
  
#print(lcm)
answer=0
for a in alist:
  answer+=(lcm-1)%a
  
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a_list = list(map(int, input().split()))
m = 1
for a in a_list:
    m = a * m // fractions.gcd(m, a)

ans = sum([(m - 1) % a for a in a_list])
print(ans)

Submission status: Accepted

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def func(q, A):
    return sum(q % a for a in A)


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

    N = ii()
    A = il()
    q = 1
    for a in A:
        q *= a
    ret = func(q - 1, A)
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd

n = input()
a = list(map(int,input().split()))
gd = reduce(gcd,a)
m = reduce(lambda a,b: a*b,a)//gd -1
sum = sum(map(lambda x: m%x,a))

print(int(sum))

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)

n=int(input())
a=list(map(int,input().split()))
t=0
for i,aa in enumerate(a):
    if i==0:
        t=a[0]
        continue
    t=lcm(t,aa)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sum_div(args):
    result = 0
    for a in args:
        result += int(a) - 1
    return result


def main():
    input()
    print(sum_div(input().split()))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce


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


def main():
    n = int(input())
    a = list(map(int, input().split()))
    m = reduce(lcm, a) - 1
    ans = 0
    for aa in a:
        ans += m % aa
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
print(sum(A)-n)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    A = list(map(int, input().split(" ")))
    subA = list(map(lambda x: x-1, A))
    print(sum(subA))

if '__main__' == __name__:
    resolve()

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


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

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

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

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

x = lcm(*a)

x = x - 1
result = 0
for i in a:
    result += x % i

print(result)

Submission status: Accepted

Solution code:
import fractions

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

lcm=1
for a in alist:
  lcm=lcm*a//fractions.gcd(lcm,a)
  
#print(lcm)
answer=0
for a in alist:
  answer+=(lcm-1)%a
  
print(answer)

Submission status: Accepted

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

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

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

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:
lennum = int(input())
numlist = list(map(int, input().split()))
_list = [i for i in numlist if i > 1]
dst = sum(_list) - len(_list)
print(dst)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
nums = [int(i) for i in input().split()]
ans = 0
for num in nums:
    ans += (num - 1)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
nums = [int(i) for i in input().split()]

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

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

l = nums[0]
for num in nums:
    l = lcm(num, l)
l -= 1
ans = 0
for num in nums:
    ans += l % num
print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np
#import math
# for AtCoder
import fractions
from collections import deque 
from functools import reduce

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

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

# N 
n = int(input())

# a1 . . . an
a = list(map(int, input().split()))

lcm_1 = lcm_list(a) - 1
m = np.mod(lcm_1, a)
print(m.sum())

Submission status: Accepted

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

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

#print(functools.reduce(func, a))
x = functools.reduce(func, a)
print(sum([(x-1) % val for val in a]))

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


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


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

l = 0
for i in range(1, len(A)):
    l = lcm(A[i - 1], A[i])
ans = l - 1
ans = sum(A) - len(A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

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

#最大公約数の個数
def ngcd(a):
    res = a[0]
    for i in range(len(a)):
        if res != 1:
            res = gcd(a[i], res)
    return res

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

#最小公倍数の個数
def nlcm(a):
    res = a[0]
    for i in range(len(a)):
        res = lcm(res, a[i])
    return res

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import collections


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    print(sum(As)-len(As))


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def Modulo(n , al):

    return sum(al) - n

def main():
    n = int(input())
    al = list(map(int , input().split()))
    print(Modulo(n , al))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc103/tasks/abc103_c
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
#list
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n=ii()
arr=limii()
p=lcm(arr)-1

ans=0
for i in range(n):
    ans+=p%arr[i]
print(ans)

Submission status: Accepted

Solution code:
def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


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

    main(n, a)

Submission status: Accepted

Solution code:

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

# 最大公約数(greatest_common_divisor)
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

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

# 最小公倍数と、比べていない数字を比べ、最小公倍数を更新する
alcm = a[0]
for i in a[1:]:
  alcm = lcm(alcm, i)

res = 0

# 関数f
for i in range(n):
  res += (alcm-1) % a[i]

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

sum = 0
for ai in a:
    sum += ai
print(sum - N)

Submission status: Accepted

Solution code:
# C
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()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

ans = 0
pi = 1

for i in range(N):
    pi *= a[i]

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

Submission status: Accepted

Solution code:

def solve():
    N = int(input())
    As = list(map(int, input().split()))

    print(sum(As)-len(As))


# Solve
if __name__ == "__main__":
    solve()

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(lambda x: int(x)-1, input().split()))
print(sum(A))

Submission status: Accepted

Solution code:
import fractions

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

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

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

    
print(f(m-1))

Submission status: Accepted

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

from fractions import gcd

def lcm(m, n):
    return (m * n) // gcd(m, n)

def lcm_list(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

f = lcm_list(a)-1
ans = 0

for i in a:
    ans += f%i

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
print(sum(a) - n)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))

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

Submission status: Accepted

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

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

    print(sum(A)-N)
resolve()

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()))
l = lcm(a[0],a[1])
for i in range(2,N):
    l = lcm(l,a[i])
ans = 0
for i in range(N):
    ans += (l-1)%a[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd

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

# ans = lcm(a) - 1
# lcm(a, b) = (a * b) // gcd(a, b)

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

ans = 0
for i in a:
    ans += LCM % i
print(ans)

Submission status: Accepted

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

k=1
for item in a:
  k=k*item//gcd(k,item)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

print(sum([int(s)-1 for s in input().split()]))

Submission status: Accepted

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

def main():
    N = int(input())
    a = tuple(map(int, input().split()))

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

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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

    lcm_A = A[0]
    for a in A:
        lcm_A = lcm(lcm_A, a)

    result = 0
    for a in A:
        result += (lcm_A - 1) % a

    print(result)


if __name__ == "__main__":
    main()