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:
def gcd(a, b) :
    if (a == 0) :
        return b
        
    return gcd(b % a, a)
 
# Function to return LCM of two numbers
def lcm(a,b):
    return (a*b) // gcd(a,b)
 
# Driver program to test above function

n=int(input())
ans=0
arr=list(map(int,input().split()))
if(n==1):
    print(arr[0]-1)
else:
    z=lcm(arr[0],arr[1])
    i=2
    while(i<n):
        z=lcm(z,arr[i])
        i+=1
ans=0
for i in range(n):
    ans+=((z-1)%arr[i])
print(ans)

Submission status: Accepted

Solution code:

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

print(sum(num)-N)

Submission status: Accepted

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

nums = [num-1 for num in nums]
print(sum(nums))

Submission status: Accepted

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

assert len(a_list) == N

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def gcd(a, b):
    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 = []
s = input().split(" ")
for i in range(N):
    A.append(int(s[i]))

tmp=lcm(A[0],A[1]);
i = 2
while  i < N:
    tmp = lcm(tmp, A[i]);
    i += 1

# print(tmp)

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

Submission status: Accepted

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

Submission status: Accepted

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

def func(m):
	ret=0
	for x in A:
		ret+=m%x
	return ret

n=1
for i in A:
	n*=i

print func(n-1)

Submission status: Accepted

Solution code:
from functools import reduce

import fractions

def gcd(x, y):
 
    if x > y:
        small = y
    else:
        small = x
    for i in range(1, small+1):
        if((x % i == 0) and (y % i == 0)):
            gcd = i
             
    return gcd
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

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

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

    v = lcm(*a) -1
    ans = sum(v % x for x in a)
    print(ans)
    
        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
mm=1
for aa in a:
    mm*=aa

mm-=1
ans=0
for aa in a:
    ans+=(mm%aa)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
ary = [int(a) for a in input().split()]
print(sum([a - 1 for a in ary]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=input()
A=A.rstrip().split(" ")
listA=[]
for i in range(N):
    listA.append(int(A[i]))
#print(listA)

B=1
for j in range(N):
    B=B*listA[j]
#print(B)

ans=0
for k in range(N):
    ans+=(B-1)%listA[k]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from functools import reduce

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

def l(a,b):
    return a*b//g(a,b)
    
def g_list(nums):
    return reduce(g, nums)

def l_list(nums):
    return reduce(l, nums, 1)


input()
li = input().split()
ili = []
for a in li:
    ili.append(int(a))
ll = l_list(ili)
ans = 0
for i in ili:
    ans += (ll-1) % i
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    print(sum([x - 1 for x in a]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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


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)


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce


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

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b // gcd(a, b)

N = input()
xs = input().split(' ')
xs = [int(x) for x in xs]
M = reduce(lcm, xs)
p = f(M-1, xs)
print(p)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions
from functools import reduce
N = int(input())
a = [int(ai) for ai in input().split()]

def f(m):
    answer = 0
    for ai in a:
        answer += m % ai
    return answer

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

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

m = lcm(a) - 1
print(f(m))

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
a = list(map(int,input().split()))
lcm = 0
ans = 0
for i in range(1,len(a)):
    if i == 1:
        lcm = (a[0]*a[1]) // gcd(a[0],a[1])
    else:
        lcm = (lcm*a[i]) // gcd(lcm,a[i])
for i in range(0,len(a)):
    ans += (lcm-1)%a[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

Submission status: Accepted

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

lcm = reduce(operator.mul, A) // reduce(gcd, A)
m = lcm - 1
print(sum(map(lambda a: m % a, A)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(a, m):
    total = 0
    for a_i in a:
        total += m % a_i
    return total


if __name__ == '__main__':
    n = int(input())
    a = map(int, input().split())
    ans = sum([a_i - 1 for a_i in a])
    print(ans)

    # n = 7
    # a_str = '994 518 941 851 647 2 581'
    # 
    # a_max = 0
    # a = []
    # for a_i_str in a_str.split():
    #     a_i = int(a_i_str)
    #     a_max = max(a_i, a_max)
    #     a.append(a_i)
    # 
    # # m \in [2, 2 * a_max - 1]
    # f_max = 0
    # for m in range(2, 2 * a_max):
    #     f_m = f(a, m)
    #     f_max = max(f_m, f_max)
    # 
    # print(f_max)
    # 
    # # for i in range(100):
    # #     a = np.random.randint(2, 100000 + 1, n)
    # #
    # #     expected = sum([a_i - 1 for a_i in a])
    # #     actual = max([f(a, m) for m in range(2, 100000 + 1)])
    # #
    # #     print(i, expected, actual)

Submission status: Accepted

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

print(sum(a)-n)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = sum(A) - len(A)
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
tt = list(map(int,input().split()))
    
ss = 1

for i in tt:
    p = []
    p.append(int(ss))
    p.append(int(i))
    q = list(sorted(p))
    while q[1] % q[0] != 0:
        r = [q[1] % q[0] , q[0]]
        s = list(sorted(r))
        q[0] = int(s[0])
        q[1] = int(s[1])

        
    ss = int(ss * i) // q[0]
num = ss
kouho = 0

for onenum in tt:
    kouho += (num-1) % onenum

print(kouho)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = [ x - 1 for x in a ]
print(sum(b))

Submission status: Accepted

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

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

n=input()
A=list(map(int, input().split(" ")))
num=A[0]
#print(A)
for i in A:
    num = lcm(num, i)
    #print(num)
value=0
for i in A:
    value+=(num-1)%i

print(value)

Submission status: Accepted

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

ans = sum(a_list) - N

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

Submission status: Accepted

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

s = 0
for a in a_l:
    s += a - 1
print(s)

Submission status: Accepted

Solution code:
import fractions


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

    lcm_temp = 1

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

    lcm_temp -= 1

    sum = 0
    for i in a:
        sum += lcm_temp % i
    print(sum)


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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import functools
n=input()
nums=map(int,input().split())
r=functools.reduce(lambda x,y: x+y,map(lambda x: x-1,nums))
print(r)

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

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

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:
import sys
sys.stdin.readline()
a = list (map(int, sys.stdin.readline().split()))

print (sum(i - 1 for i in a) )

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
l = list(map(int, input().split()))
res = 0

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

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

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

main()

Submission status: Accepted

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

ans = 0
x = 1

for a in A:
    x *= a

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

print(ans)

Submission status: Accepted

Solution code:
import sys
import fractions

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

max_a = max(a)

tmp = a[0]
for i in a[1:]:
    tmp = (tmp * i) // fractions.gcd(tmp, i)

tmp -= 1
f = 0
for j in a:
    f += tmp % j
print(f)

Submission status: Accepted

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

result = 0
for ai in a:
    result += ai - 1

print(result)

Submission status: Accepted

Solution code:
from fractions import gcd

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

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

m = aa[0]
for a in aa[1:]:
  m = lcm(m, a)
  
m = m - 1
ans = 0
for a in aa:
  ans += m % a
  
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int, input().split()))
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def lcm(i,j):
    return i*j//gcd(i,j)
k=1
for t in a:
    k=lcm(k,t)
k-=1
ans=0
for t in a:
    ans+=k%t
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:
#! /usr/bin/env python3

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

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

print(res)

Submission status: Accepted

Solution code:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
def lcm(x, y):
    return (x * y) // gcd(x, y)
n = int(input())
a = list(map(int,input().split()))
x = 1
for i in range(n-1):
    x *= lcm(a[i],a[i+1])
Sum = 0
for i in range(n):
    Sum += (x-1)%a[i]
print(Sum)

Submission status: Accepted

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

ans = sum(A) - N

print(ans)

Submission status: Accepted

Solution code:
N=int(input())

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

print(sum(li)-N)

Submission status: Accepted

Solution code:
n = int(input())
a = map(int, input().split(' '))
ans = 0

for i in a:
    ans += i - 1

print(ans)

Submission status: Accepted

Solution code:
input()
print(sum(map(lambda e:int(e)-1,input().split())))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding=utf-8

if __name__ == '__main__':
    N = int(input())
    number_list = list(map(int, input().split()))

    print(sum([i-1 for i in number_list]))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    return sum(a) - N

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

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

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

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

#r = sum((l - 1) % a for a in A)
r = sum(a - 1 for a in A)

print(r)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(array) - N)

Submission status: Accepted

Solution code:
import fractions as math

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

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

l = a[0]
for num in a[1:]:
    l = lcm(num, l)

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

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

N = int(input())

A = list(map(int, input().split()))
M = 1

for a in A:
    M = a * M // gcd(a, M)

print(sum([(M - 1) % a for a in A]))

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))
    s = 0
    for i in range(N):
        s += A[i] - 1
    print s


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

M=max(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
b=1
for i in range(n):
 b*=a[i]
b-=1
c=0
for i in range(n):
 c+=b%a[i]
print(c)

Submission status: Accepted

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

print(sum(A_list) - N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def c_modulo_summation(N, A):
    ans = 0
    for a in A:
        ans += a-1
    return ans

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(sum(a)-n)

Submission status: Accepted

Solution code:
import sys
from functools import reduce
sys.stdin.readline()
As = list(map(int, sys.stdin.readline().split()))
print(sum(As)-len(As))

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:
from numpy import *
from scipy import *
from sys import *

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

print(sum(a)-n)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    xs = [int(s) for s in input().split()]
    print(sum(xs) - n)

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

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

N = getN()
nums = getList()


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

Submission status: Accepted

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

Submission status: Accepted

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

M = 0
for i in A:
	M += i - 1

print(M)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
 
N=int(input()) 
S=list(map(int,input().split()))
 
ans=sum(S)-N

    
 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ret = 0
for x in l:
  ret += x-1

print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a_sum = sum(A)

print(a_sum-N)

Submission status: Accepted

Solution code:
n = int(input())
arr = map(int,raw_input().split())

ans = 0

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

Submission status: Accepted

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

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:
import itertools as it
import collections as col

import sys
sys.setrecursionlimit(10000)

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

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

if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
def gcd(a, b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


N = int(raw_input())
A = [int(x) for x in raw_input().split()]

X = 1
for i in A:
    X = lcm(i, X)

sum = 0
X -= 1
for i in A:
    sum += X % i

print(sum)

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(raw_input())
l = [int(x) for x in raw_input().split()]
print sum(l) - 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()))

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

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

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

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

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)


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

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

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

    print(ans)


if __name__ == '__main__':
    main()

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:
N = int(input())
As = [int(s) for s in input().split()]

print(sum(As) - 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:
print -input() + sum(map(int, raw_input().split()))

Submission status: Accepted

Solution code:
import fractions

n = int(input())
P = list(map(int, input().split()))
a = 1
for i in range(n):
    a = a * P[i] // fractions.gcd(a, P[i])

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = raw_input()
x = map(int, raw_input().split())
print sum(t-1 for t in x)

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

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

Submission status: Accepted

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

Submission status: Accepted

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

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)
x=1
for t in a:
    x=lcm(x,t)
x-=1
ans=0
for t in a:
    ans+=x%t
print(ans)

Submission status: Accepted

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(1,N):
  l = l * a[i] // math.gcd(l, a[i])
m = l-1
fm = 0
for i in range(N):
  fm += m % a[i]
print(fm)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    m = l-1

    # f
    fm = 0
    for i in range(N):
        fm += m % a[i]
    print(fm)

Submission status: Runtime Error

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

m = l-1

# function
fm = 0
for i in range(N):
  fm += m % a[i]
print(fm)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

コンテスト時間: 2018-07-21(土) 21:00 ~ 2018-07-21(土) 22:40 (100分)AtCoderホームへ戻る
 トップ
 問題
 質問
 提出
 提出結果
 順位表
 バーチャル順位表
 コードテスト
 解説
コードテスト
言語

ソースコード
)
1
N = int(input())
2
a = list(map(int, input().split()))
3
a.sort(reverse=True)
4
​
5
# ユークリッドの互除法により最大公約数を求める
6
ans = 0
7
val1, val2 = a[0], a[1]
8
while 1:
9
  if val1 % val2 == 0:
10
    ans = a[0]*a[1]/val2
11
    break
12
  else:
13
    tmp = val2
14
    val2 = val1 % val2
15
    val1 = tmp
16
​
17
for i in range(2, N):
18
  val1, val2 = ans, a[i]
19
  while 1:
20
    if val1 % val2 == 0:
21
      ans = ans*a[i]/val2
22
      break
23
    else:
24
      tmp = val2
25
      val2 = val1 % val2
26
      val1 = tmp
27
​
28
f_ans = 0
29
for i in range(N):
30
  f_ans += (ans-1)%a[i]
31
print(int(f_ans))
32
  
33
      
34
  
※ 512 KiB まで
※ ソースコードは「Main.拡張子」で保存されます

  
標準入力
7
994 518 941 851 647 2 581
※ 512 KiB まで

終了コード	0
実行時間	17 ms
メモリ	2964 KB
標準出力
4527

標準エラー出力
FacebookTwitterHatena共有
ルール 用語集
利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求
Copyright Since 2012 ©AtCoder Inc. All rights reserved.

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#最小公倍数でループ
import math
n = int(input())
ans = list(map(int,input().split()))
lcm = ans[0]
for k in ans:
    gcd = math.gcd(lcm, k)
    lcm = round(lcm*k/gcd)
    print(lcm)


an =0
for k in ans:
    an += (lcm-1)%k
        
print(an)