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:
# C - Modulo Summation
# https:C - Modulo Summation//beta.atcoder.jp/contests/abc103/tasks/abc103_c

# C_Modulo_Summation.py

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

limit = 1
highest = 0
for a in A:
    limit *= a
    highest += a-1
#print(limit, highest)

max_f = 0
i = limit
while True:
    f = 0
    for a in A:
        f += i % a
    if f > max_f:
        max_f = f
    if max_f == highest:
        break
    if i==0:
        break
    i -= 1
print(max_f)

Submission status: Accepted

Solution code:

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

    """
    gcd = a[0]
    lcm =0
    for i in range(1,len(a)):
        gcd = math.gcd(gcd,a[i])
        lcm = reduce(mul,a[:i+1])//gcd
        print(gcd)
        #print(lcm)
        #print(a[i])
    """
    ans= 0
    for i in a:
        ans += (i-1)

    print(ans)


if __name__ == "__main__":
        main()

Submission status: Accepted

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

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

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

for i in range(2,len(a)):
	tlcm = lcm(a[i],tlcm)

tlcm = tlcm - 1
result = 0
for i in range(len(a)):
	result += tlcm % a[i]
print(result)

Submission status: Accepted

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

Answer=0
for Amap in A:
  Answer = Answer + Amap -1

print(Answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
import operator
from functools import reduce
def gcd(a,b):
    c = 0
    while a != b:
        if a&1==b&1==0:
            a, b = a>>1, b>>1
            c += 1
        elif min(a,b) == 0:
            a = max(a,b)
        else:
            a, b = max(a,b)%min(a,b), min(a,b)
    return a*2**c


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

def solve():
    N = int(input())
    *A, = map(int, input().split())
    m = reduce(lcm, A) - 1
    s = sum([m%a for a in A])

    return str(s)

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

Submission status: Accepted

Solution code:
def gcd(a, b):
    a,b = min(a,b),max(a,b)
    while b:
	    a, b = b, a % b
    return a

#least multi
def lm(a,b):
    return a*b // gcd(a,b)

N =input()
list = input().split(" ")
int_li = [int(s) for s in list]

m = 1
for i in int_li:

    m = lm(m,i)
m-=1

ans = 0
for i in int_li:
    ans += m%i

print(ans);

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 3
import math

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

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

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

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

def lcm_list(numbers):
    ans=numbers[0]
    for i in range(1,len(numbers)):
        ans=lcm_base(ans,numbers[i])
    return ans

m= lcm_list(a)-1
print(f(m,a))

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)

def mod_(a_list, m):
    sum_ = 0
    for a in a_list:
        sum_ += m % a

    return sum_


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

lcm_ = lcm_list(a)

print(mod_(a, lcm_-1))

Submission status: Accepted

Solution code:
def gcd(m,n):
    while n!=0:
        l=n
        n=m%n
        m=l
    return m

def lcm(p,q):
    return p*q//gcd(p,q)

N=int(input())
a=list(map(int,input().split(' ')))
lcm_=lcm(a[0],a[1])
for i in range(2,len(a)):
    lcm_=lcm(lcm_,a[i])
result=0
m=lcm_-1
for i in a:
    result+=m%i
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

import functools

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

mod = functools.reduce(lambda x,y: x*y, a)

print(sum([(mod-1)%i for i in 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())
L = list(map(int,input().split()))
answer = 0
for i in range(N) :
    L[i] -= 1
    answer += L[i]

print(sum(L))

Submission status: Accepted

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

num = sum(a - 1 for a in A)
print(num)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in list(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()))

m = 1
for a_ in a:
    m *= a_
m -= 1
f = 0
for a_ in a:
    f += m % a_
print(f)

Submission status: Accepted

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

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

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

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

f = 0
for a in A:
    f += (lcm-1) % a
print(f)
#max_f = 0
#for i in range(lcm):
#    f = 0
#    for a in A:
#        f += i % a
#    print(i, f)
#    max_f = max(max_f, f)
#print(max_f)

Submission status: Accepted

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

x=1
for a in A:
    x*=a

print(sum(list(map(lambda a:(x-1)%a,A))))

Submission status: Accepted

Solution code:
from fractions import gcd
from functools import reduce

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

a = sorted(a)

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

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

temp = lcm_list(a) - 1

result = 0
for i in a:
    result += temp % i

print(result)

Submission status: Accepted

Solution code:
def main():
        run()

def run():
        n = int(input())
        data = [int(x) for x in input().split(" ")]

        max_sum = 0 
        max_m = max(data)

        for num in data:
                max_sum += num - 1
        print(max_sum)



if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

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

Submission status: Accepted

Solution code:
inp = [input() for _ in range(2)]
n = int(inp[0])
a = inp[1].split()

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

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

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

a_lcm = multi_lcm(a)
x = a_lcm - 1

score = 0
for i in range(n):
    score += x % a[i]

print(score)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
#coding: UTF-8
import sys
import os
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())
m=list(map(int,input().split()))
k=lcm_list(m)
k=k-1
answer=0
for i in range(n):
    answer=answer+(k%m[i])
print(answer)

Submission status: Accepted

Solution code:
def gcd(x, y):
   while(y):
       x, y = y, x % y

   return x

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

cnt = int(input())
nums = [int (i) for i in input().split(" ")]
badnumber = 1
answer = 0
for i in range(0,cnt):
	badnumber = lcm(nums[i],badnumber)
badnumber=badnumber-1
for i in range(0,cnt):
	answer=answer+badnumber%nums[i]
print(answer)

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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


def func(m, a):
    val = 0
    for i in a:
        val += m % i
    return val


def main():
    n = input()
    a = list(map(int, input().split(' ')))
    itrmax = lcm_list(a)

    #max_val = max([func(i, a) for i in range(itrmax)])
    max_val = func(itrmax-1, a)
    print(max_val)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(raw_input())
# スペース区切りの整数の入力
l = map(int, raw_input().split())

c = 1
for a in l:
	c=c*a

ret= sum([(c-1)%a for a in l])
print ret

Submission status: Accepted

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

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

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

koubai = lst[0]
for i in range(n):
    if i != 0:
        koubai = lcm(lst[i], koubai)
vol = 0        
for i in range(n):
    vol += (koubai - 1) % lst[i]
print(vol)

Submission status: Accepted

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

"""
for i in A:
    B=2*i-1
    res_pre=0
    for j in A:
        res_pre+=B%j
        if(res<res_pre):
            res=res_pre

B=2*A[0]-1
for i in range(0,A[0]-1):
    res_pre=0
    for j in A:
        res_pre+=(B-i)%j
    print(res_pre)
    if(res<res_pre):
        res=res_pre

print(res)

for i in range(0,1100000):
    res=0
    for j in A:
        res+=i%j
    if(res==90):
        print("Y")
        print(i)
"""
res=1
resres=0
for i in A:
    res*=i
res-=1
for i in A:
    resres+=res%i
print(resres)

Submission status: Accepted

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

   
n = int(input())

a = list(map(int,input().split()))
lcm = a[0]
for i in a[1:]:
  lcm = (lcm * i) // int(gcd(lcm, i)) 

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

Submission status: Accepted

Solution code:
N = raw_input()
print sum(map(lambda x: x - 1, map(int, raw_input().split())))

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int, input().rstrip().split()))
work=int()
Multiple=int(1)
Output=int(0)
def gcd(x,y):
    while y>0:
        x, y=y, x%y
    return x
for i in range(N):
    Multiple=int((Multiple*a[i])//gcd(Multiple, a[i]))
for i in range(N):
    Output+=(Multiple-1)%a[i]
print(Output)

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


a_lcm = reduce(lambda x, y: (x * y) // gcd(x, y), a)
m = a_lcm - 1
a_mod = [m % ax for ax in a]

print(sum(a_mod))

Submission status: Accepted

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

Submission status: Accepted

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

    f = sum(x - 1 for x in a)
    print(f)

main()

Submission status: Accepted

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

cnt=0
f=0
for i in l:
    f += i-1
print(f)

Submission status: Accepted

Solution code:
import sys

N = int(sys.stdin.readline().strip())
a = [ i - 1 for i in map(int, sys.stdin.readline().strip().split())]

print(sum(a))

Submission status: Accepted

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

m = 0
for j in range(N):
   m += lis[j] - 1

print(m)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

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

print(sum(A)-N)

Submission status: Accepted

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

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

summ2 = 0
for i in a:
    summ2 += (summ-1)% i

print(summ2)

Submission status: Accepted

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

Submission status: Accepted

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



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


def lcm_list(*numbers):
    return reduce(lcm, numbers)
a_lcm=lcm_list(*a)
a_lcm=a_lcm-1
for i in range(n):
    f+=a_lcm % a[i]
print(f)

Submission status: Accepted

Solution code:
N = int(input())
As = 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)


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

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

print(ans)

Submission status: Accepted

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

print(sum(nums)-n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

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

    a_list = map(lambda x: x - 1, a_list)
    print(sum(list(a_list)))


    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/7/21 20:19
# @Version : 1.1
# @Author  : Jade
# @File    : acm.py
# @Software: PyCharm
#
n = int(input())
a = map(int,input().split(' '))
print(sum(a) - n)

Submission status: Accepted

Solution code:
def main():
    """
    2 <=  N <= 10^3
    2 <= ai <= 10^5

    非負整数 m に対して
    f(m) = (m mod a1) + (m mod a2) + (m mod aN)
    f_max

    mの制約は問題文中には直接記述されていない
    """
    N = int(input())
    *A, = map(int, input().split())

    ans = f(N, A)
    print(ans)


def f(N, A):
    """
    直感: 最小公倍数,最大公約数
        最小公倍数のm ならすべてのaで割り切れる
        つまり最小公倍数-1 ならすべてのaについて m mod ai = ai - 1

    m=a_MAX-1, (m mod a_MAX) が最大
    ただし他のa=a_MAX-1 の場合、f(m)は小さくなってしまう
    aiに対して1 <= m <= a_Max-1 をすべて試す: 10^5 * 3 * 10^3 => TLE
    """
    try:
        # py3.5
        from math import gcd
    except:
        from fractions import gcd

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

    m1 = lcm(A[0], A[1])
    for a in A[2:]:
        m1 = lcm(m1, a)

    m = m1 - 1
    ans = sum(m % a for a in A)

    return ans


def WA(N, A):
    ans = 0
    m_max = max(A) * 2 - 1
    for m in range(1, m_max):
        mods = [m % a for a in A]
        tmp = sum(mods)
        print(*(mods + [tmp]), sep="\t")
        ans = max(ans, tmp)

    return ans


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(i) - 1 for i in input().split()]

print(sum(A))

Submission status: Accepted

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


def lcm(x, y):
    x2=x
    y2=y
    while y != 0:
        x, y = y, x%y
    return (x2 * y2) // x

while(len(ac)>1):
    x=ac.pop()
    y=ac.pop()
    ac.append(lcm(x, y))

g=ac[0]-1

ans=0
for i in a:
    ans+=g%i

print(ans)

Submission status: Accepted

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

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

print(r)

Submission status: Accepted

Solution code:
from functools import reduce

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

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

c = lcm_list(a)-1
print(sum([c % b for b in a]))

Submission status: Accepted

Solution code:
kick=input()
inp=input().split()
b=False
sum=0
for i in inp:
    i=int(i)
    sum+=(i-1)
print(sum)

Submission status: Accepted

Solution code:


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

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

def lcm_n(arr):
    l = arr[0]
    for i in range(len(arr)-1):
        l = lcm(l,arr[i+1])
    return l

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

g = lcm_n(arr)-1
out = 0


for i in arr:
    out += g%i

print(out)

Submission status: Accepted

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
a = Is()
m = 1
for e in a:
    m = m*e
m -= 1
f = 0
for e in a:
    f += m%e
print(f)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
# your code goes here
n = input()
l = input().split()
sum = 0
for i in range(len(l)):
	sum += int(l[i])-1
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

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

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

# f = [0 for i in range(koubai)]

# for i in range(len(f)):
#     for j in range(N):
#         f[i] += i % a[j]

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

print(sum)

Submission status: Accepted

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

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

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

j=lcm(A[0],A[1])
for i in range(2,len(A)):
    j=lcm(j, A[i])

tmp=[]
for i in A:
    tmp.append((j-1)%i)
ans=sum(tmp)
print(ans)

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
import math

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

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

print(ret)

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

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

m=lcm_list(l)
f=0

for i in range(n):
  f+=(m-1)%l[i]
  
print(f)

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)

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

m = lcm(A) - 1
f = 0
for i in range(N):
    f += m % A[i]
print(f)

Submission status: Accepted

Solution code:
# coding: utf-8

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

print(sum(a) - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import statistics
import math
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())
nums = list(map(int, input().split()))
lcm = lcm_list(nums)

# print(nums, lcm)
sum =0
for num in nums:
    sum += (lcm-1)%num
print(sum)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

print(sum(a)-n)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# 文字列入力
'''
S = input()
A, B = input().split()
'''

# 文字列分解（['A', 'B', 'C']）
'''
S = list(input())
'''

# 整数入力
'''
X, Y, Z = map(int, input().split())
X, Y, Z = list(map(int, input().split()))
'''

# リストのユニーク化（順破壊）
'''
L = ['a', 'a', 'b']
L = list(set(L))
'''

# 固定長リスト最速初期化
'''
L = [None] * N
'''

# 二進数でフラグパターンを全種作成
'''
import numpy as np

N = 3
f = []

for i in range(0, 2**N):
    string = str(bin(i))[2:]
    f.append(['0'] * (N - len(string)) + list(string))

F = np.array(f)
F = (F == '1')
'''

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)


N = int(input())
A = list(map(int, input().split()))
L = lcm(A) - 1

result = 0

for a in A:
    result += (L % a)

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def run():
	N = input()
	ls = [int(x) - 1 for x in input().split()]

	print(sum(ls))

if __name__ == '__main__':
	run()

Submission status: Accepted

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

    sum = 0
    for alpha in a:
        sum = sum + alpha

    print(sum - n)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list( map(int, input().split()) )	# 1 2 3 4 5 ...

from fractions import gcd

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

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

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = input()

total = 0
for i in range(n):
    total += int(a.split()[i])

total -= n

print(total)

Submission status: Accepted

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


sum = 0
for x in a:
    sum += x-1

print(sum)

Submission status: Accepted

Solution code:
import functools

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

lcmVal = int(functools.reduce(lcm, a, 0))
print(sum(map(lambda x: (lcmVal-1) % x, a)))

Submission status: Accepted

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

result = 0
for i in range(N):
    result += ls_a[i] - 1

print(result)

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int, input().split()))
lcm = 0
for e in arr:
    lcm += e - 1
print(lcm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = int(input())
a = [i for i in map(int , input().split())]

print(sum(a)-n)

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:
# your code goes here
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 fractions
from functools import reduce

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

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

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)

m = lcm_list(a) - 1
print(f(m, a))

Submission status: Accepted

Solution code:
from functools import reduce

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

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

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

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

c = lcm_list(a) - 1

f = 0
for i in a:
    f += c % i

print(f)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 21 19:19:13 2018
ABC103C
@author: maezawa
"""

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

print(sum(a)-n)

Submission status: Accepted

Solution code:
import fractions
import functools
from operator import mul

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

def gcdmult(lis):
    return(functools.reduce(fractions.gcd,lis))

lcmmult = lambda x: (functools.reduce(mul,x))//gcdmult(x)
lcma = lcmmult(aas)

ans = sum(map(lambda x: (lcma-1)%x,aas))
print(ans)

Submission status: Accepted

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

def get_gcd(a,b):
        if a<b:
                a,b = b,a

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

def get_lcm(a,b):
        return a*b//get_gcd(a,b)

def get_lcm_list(numbers):
        ans = get_lcm(numbers[0],numbers[1])
        for i in range(2,len(numbers)):
                ans = get_lcm(ans,numbers[i])
        return ans

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

from functools import reduce

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

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def f(num, aN):
    sum1 = 0
    for i in range(len(aN)):
        sum1 += num % aN[i]
    return sum1

# リストの最小公倍数-1を関数fの引数にする
lcm = lcm_list(aN)
print(f(lcm-1, aN))

Submission status: Accepted

Solution code:
N = int(raw_input())
A = [int(c) for c in raw_input().split()]

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

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()))
for i in range(n-1):    
    if(i==0):
        m=lcm(a[0],a[1])
    else:
        m=lcm(m,a[i+1])
m-=1
f=0
for i in range(n):
    f+=m%a[i]
print(f)

Submission status: Accepted

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

print(sum(a) - n)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding:utf-8

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

# 与えられたaの最小公倍数 - 1が剰余modの和が最大となる
f = 0
for i in a:
    f += 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:
N = int(input())
a = list(map(int, input().split()))
ans = sum(a) - N
print(ans)

Submission status: Accepted

Solution code:
n=input()
w=[]
w=raw_input().split()
w=[int(x)for x in w]
s=1
for i in range(n):
    s=s*w[i]
s=s-1
t=0
for i in range(n):
   t+=s%w[i]
print t

Submission status: Accepted

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

max_sum = 0

for num in n_list:
  max_sum += (num - 1)

print(max_sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(X)

Submission status: Accepted

Solution code:
import math
import functools
N = int(input())
T = [int(i) for i in input().split()]

def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)

def lcm(A, B):
  return int(A * (B // gcd(A, B)))


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

Submission status: Accepted

Solution code:
def find_lcm(num1, num2):
    if(num1>num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm
n=  int(raw_input())
arr = map(int, raw_input().split())
lc = find_lcm(arr[0], arr[1])
for i in range(2, n):
    lc = find_lcm(lc, arr[i])
lc -= 1
ans = 0
for i in xrange(n):
    ans += (lc % arr[i])
print ans

Submission status: Accepted

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

for j in range(N):
    num += a[j] - 1

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import fractions
N = int(input())
ai = list(map(int, input().split()))
m = 1
ans = 0
for a in ai:
    m = (m * a) // fractions.gcd(m, a)
m -= 1
for a in ai:
    ans += m % a

print(ans)

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

sum = -n 
for item in a:
    sum += item
print(sum)