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:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


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


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


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

if __name__ == '__main__':
    main()

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)
aa = a[0]
for i in a[1:]:
	aa = lcm(aa,i)
#if aa-max(a) <= 0:
#	aa += aa
s = 0
for i in a:
	s += (aa-1)%i
print (s)

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)
aa = a[0]
for i in a[1:]:
	aa = lcm(aa,i)
if aa-max(a) <= 0:
	aa += aa
s = 0
for i in a:
	s += (aa-1)%i
print (s)

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 = [int(i) for i in input().split()]
print(sum(a) - len(a))

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

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

Submission status: Accepted

Solution code:
n = int(input())
*a, = map(int, input().split())
f = 0
for ai in a:
    f += ai - 1
print(f)

Submission status: Accepted

Solution code:
from fractions import gcd

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

p = A[0]
for a in A:
    p = (p * a) // gcd(p, a)

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

print(ans)

Submission status: Accepted

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

from fractions import gcd

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

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

m -= 1

ans = 0
for a in A:
    ans += m % 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:
import numpy
N = int(input())
L = [i-1 for i in map(int,input().split())]
res = numpy.sum(L)
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:
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#abc103 c
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()))
print(sum(A)-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()))

print(sum(a)-n)

Submission status: Accepted

Solution code:
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque

import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
# 配列入力の受け取り
arrA = np.array(input().split(),dtype=np.int64)

ans = sum(arrA -1)

print(ans)

Submission status: Accepted

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

def gcd_impl(n,m):
    K = 5
    for _ in range(80):
        t = n - m
        s = n - m*K
        q = t < m
        p = t < m*K
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
        if p:
            n = n
        else:
            n = s
    return gcd_impl(m, n%m)

def gcd_pre(n,m):
    for _ in range(4):
        t = n - m
        q = t < m
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
    return gcd_impl(n,m)

def gcd(n,m):
    if n > m:
        return gcd_pre(n,m)
    else:
        return gcd_pre(m,n)

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

def lcm_list(lst):
    return reduce(lcm, lst)

M = lcm_list(a) - 1

res = 0
for i in a:
    res += M%i
print(res)

Submission status: Accepted

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

def gcd_impl(n,m):
    for _ in range(10):
        t = n - m
        q = m > t
        if q:
            n = m
        else:
            n = t
        if q:
            m = t
        else:
            m = m
        if m == 0:
            return n
    return gcd_impl(m, n%m)

def gcd(n,m):
    if n > m:
        return gcd_impl(n,m)
    else:
        return gcd_impl(m,n)

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

def lcm_list(lst):
    return reduce(lcm, lst)

M = lcm_list(a) - 1

res = 0
for i in a:
    res += M%i
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
# 中国剰余定理より f(m)=(a_1-1) + ... + (a_n -1) を満たすmが存在する.
print(sum(A)-n)

Submission status: Accepted

Solution code:
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

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

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

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 = sys.stdin.readline
N = int(input())
a = [int(x) for x in input().split()]

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

Submission status: Accepted

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

from fractions import gcd 

x =1
for i in l:
    x = x * i // gcd(x, i)

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(y)

Submission status: Accepted

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

from fractions import gcd 

def lcms(List):
    __ = 1
    for _ in List:
        __ =int(__ * _ // gcd(__, _))
    return __

x = lcms(l)-1

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

print(y)

Submission status: Accepted

Solution code:
"""
103 C
"""

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))
    return n, alist


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 submit():
    n, alist = read_input()

    c = 1
    for a in alist:
        c = lcm(c, a)

    res = 0
    for a in alist:
        res += (c - 1) % a

    print(res)
    

if __name__ == "__main__":
    submit()

Submission status: Accepted

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

from fractions import gcd 

x =1
for i in l:
    x = x * i // gcd(x, i)

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(int(y))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
t = 0

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
n = int(input())
a = list(map(int, input().split()))
def function(m, a):
  count = 0
  for i in a:
    count += m%i
  return count
def lcm_base(x, y):
    return (x * y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
max_num = lcm(*a)-1
print(function(max_num, a))

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

ans = 0
l = 1

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

print(ans)

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)

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

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

print(sum((l - 1) % a for a in A))

Submission status: Accepted

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

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 = [int(x) for x in input().split()]

print(sum(a) - N)

Submission status: Accepted

Solution code:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
def nlcm(lista):
    res = lista[0]
    for i in range(1,len(lista)):
        res = lcm(res,lista[i])
    return res

def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n = int(input())
    a = list(map(int, input().split()))
    cm = nlcm(a)-1
    res = 0
    for i in a:
        res += cm % i
    print(res)

if __name__ == '__main__':
    main()

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()))
ans = 0
m = 1
for i in range(n):
    m *= a[i]

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

print(ans)

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

Solution code:
n=int(input())

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

ans = 0

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

Submission status: Accepted

Solution code:
N = int(input())
ARR = [int(s) for s in input().split(" ")]
def calculate(arr,n):
    return sum(arr) - n

result = calculate(ARR,N)
print(result)

Submission status: Accepted

Solution code:
import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd

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

x = a[0]

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

x = x-1

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

print(ans)

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

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

m = 1
for x in a:
    m *= x
print(f(m-1, a))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    A = [int(e) for e in input().split()]

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

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:
lis=[]
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()))
print(sum(a) - len(a))

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

Submission status: Accepted

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

print(sum(a_list)-N)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

print(sum(a - 1))

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from itertools import accumulate
def gcd(n,m):
    n,m = max(n,m),min(n,m)
    r = n % m
    while r > 0:
        n,m = m,r
        r = n % m
    return m
def lcm(n,m):
    return n*m//gcd(n,m)
N = int(input())
a = list(map(int,input().split()))
L = list(accumulate(a, lcm))[-1]

def f(n):
    return sum([n%x for x in a])
print(f(L-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)
LCM = lcm(a[0], a[1])
# print(LCM, a[0], a[1])
for i in range(2, N):
    LCM = lcm(LCM, a[i])
answer = 0
for aN in a:
    answer += (LCM - 1) % aN
    # print(LCM, aN)

print(answer)

Submission status: Accepted

Solution code:
N = input()
a = map(int,input().split())
ans = 0
for ai in a:
  ans += ai-1
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:
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()))
for i in range(N):
    A[i] -= 1
print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(zz) for zz in input().split()]

print(sum(A)-N)

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    N=int(input())
    As=list(map(int,input().split()))
    f=0
    for a in As:
        f+=a-1
    print(f)

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

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

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

Submission status: Accepted

Solution code:
#103_C
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:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
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:
import fractions
from functools import reduce
def b(x, y):
    return (x * y) // fractions.gcd(x, y)
_ = int(input())
a = [int(x) for x in input().split()]
m = reduce(b, a, 1) - 1
print(sum([m % a_i for a_i in a]))

Submission status: Accepted

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

m = 1
for a in A:
    m*=a
m -=1
print(sum(m % a for a in A))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=l[i]
print(sum-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:
import fractions

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

N=int(input())
a=list(map(int,input().split()))
tmp=a[0]
for i in range(1,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:
# coding: utf-8
import math
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
N=int(input())
A=list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
# coding: utf-8
from fractions import gcd
def lcm(a, b):
    return a*b//gcd(a, b)
N = int(input())
A = list(map(int, input().split()))
m = A[0]
for i in range(1, N):
    m = lcm(m, A[i])
ans = 0
m -= 1
for i in range(N):
    ans += m % A[i]
print(ans)

Submission status: Accepted

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

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

def gcd2(number):
    return reduce(gcd, number)

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

m = lcm2(a) - 1
#print(m)
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 = list(map(lambda x:x-1,a))
print(sum(ans))

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


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

Submission status: Accepted

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

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:
# 2020/02/11
# AtCoder Beginner Contest 103 - C

import math
import fractions

# Greatest Common Divisor(GCD)  
def gcd_fgf(a, b):
    return fractions.gcd(a, b)

# Least Common Multiple(LCM)
def lcm_fgf(a, b):
    return int(a * b // fractions.gcd(a, b))

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

# Calc Co-LCM
work_lcm = a[0]
for i in range(1, n):
    work_lcm = lcm_fgf(work_lcm, a[i])

m = work_lcm - 1

# Sum remains
fm = 0
for i in range(n):
    fm = fm + (m % a[i])

ans = fm    
# Output
print(ans)

Submission status: Accepted

Solution code:
# 2020/02/11
# AtCoder Beginner Contest 103 - C

import math
import fractions

# Greatest Common Divisor(GCD)  
def gcd_fgf(a, b):
    return fractions.gcd(a, b)

# Least Common Multiple(LCM)
def lcm_fgf(a, b):
    return int(a * b // fractions.gcd(a, b))

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

# Calc Co-LCM
work_lcm = a[0]
for i in range(1, len(a)):
    work_lcm = lcm_fgf(work_lcm, a[i])

m = work_lcm - 1

# Sum remains
fm = 0
for i in range(len(a)):
    fm = fm + (m % a[i])

ans = fm    
# Output
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd


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


def main():
    number = int(input())
    mods = list(map(int, input().split(" ")))
    be_divided = reduce(find_lcm, mods) - 1
    answer = 0
    for mod in mods:
        answer += be_divided % mod
    print(answer)


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(ls):
  return reduce(lcm_base,ls)

def mod(ls,num):
    ans=0
    for i in range(N):
        ans+=num%ls[i]
    return ans
print(mod(a,lcm(a)-1))

Submission status: Accepted

Solution code:
s = int(input())
ss = input().split()
sss = []
for i in ss:
    sss.append(int(i))
print(sum(sss)-s)

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(N):
    g=gcd(lcm,a[i])
    lcm=(lcm*a[i])//g
    
lcm-=1

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

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


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

N = int(input())
alist = list(map(int, input().split()))
l = lcm_list(alist)
ans = 0
for a in alist:
    ans += (l - 1) % a
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])
target = ans - 1
sum = 0
for aa in a:
    sum += target%aa
print(sum)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
print(sum(a)-n)

Submission status: Accepted

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

print(sum(numbers) - N)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
import fractions
from functools import reduce
def lcm_base(x,y):
	return (x * y) // fractions.gcd(x,y)
def lcm(*numbers):
	return reduce(lcm_base,numbers,1)
mod = lcm(*a) - 1
ans = 0
for i in range(N):
	ans += mod % a[i]
print(ans)

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
import fractions
#from scipy.misc import comb

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

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

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

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

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

sum = 0

for n in nums:
    sum += n - 1

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

for i in a:
    ans += i - 1

print(ans)

Submission status: Accepted

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

lcs = 1
for i in range(N):
    lcs = (lcs * A[i]) // gcd(lcs, A[i])
ans = 0
for i in range(N):
    ans += (lcs-1) % A[i]
print(ans)

Submission status: Accepted

Solution code:
import fractions
import functools

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

lcm = functools.reduce(lambda x, y: (x * y) // fractions.gcd(x, y), a) - 1

print(sum(map(lambda x: lcm % x,a)))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans=0

for aa in a:
    ans+=aa-1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
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(map(int, input().split()))
ans = 0
x = lcm_list(a) - 1
for i in range(n):
  ans += x%a[i]
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]

class Util():
    def round_up(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

N = cin.int()
A = cin.mapInt()
print(sum(A) - N)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

mod = 1000000007

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

def gcd(m, n):
	if n == 0:
		return m
	return gcd(n, m % n)

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

n = ni()
a = na()

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

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

print(ans)

Submission status: Accepted

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
val = a[0]
for i in range(1, n):
    val = val*a[i] // fractions.gcd(val,a[i])
m = val -1
#print(m)
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()))
t=0

print(sum(A)-N)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(f(m-1, a))

Submission status: Accepted

Solution code:
N = int(input())
AN = map(int, input().split())
 
print(sum(AN)-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:
from fractions import gcd

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

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

Submission status: Accepted

Solution code:
def minus1int(x):
  return int(x) - 1

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

print(sum(a))