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: Wrong Answer

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


def calcMod(a, m):
  return sum([m % v for v in a])


print(max([calcMod(a, m) for m in range(1, max(a))]))

Submission status: Wrong Answer

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


def calcMod(a, m):
  return sum([v % m for v in a])


print(max([calcMod(a, m) for m in range(1, max(a))]))

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline

N=int(input().strip())
inf=1000000007

ans=0
for i in range(1,N+1):
    ans+=(i**10-(i-1)**10)*(math.floor(N/i)**10)
print(ans%inf)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug  6 17:15:00 2018

@author: Yuki
"""

N = int(input())

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

def get_f_value(m, A):
    mod_list = [m%i for i in A]
    return sum(mod_list)

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

def get_lcm_from_list(A):
    lcm_list = [lcm(A[i], A[i+1]) for i in range(len(A)-1)]
    return max(lcm_list)

lcm_value = get_lcm_from_list(A)
res = []
for m in range(lcm_value):
    res.append(get_f_value(m, A))
print(max(res))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

b = a

ans = 0

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

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

def lcm_list(l):
    for i in range(len(l)):
        if i == len(l) - 1:
            break
        l[i+1] = lcm(l[i], l[i+1])
    return l[len(l) - 1]

for i in range(len(a)):
    ans += (lcm_list(a) - 1) % b[i]
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = 0

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

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

def lcm_list(l):
    for i in range(len(l)):
        if i == len(l) - 1:
            break
        l[i+1] = lcm(l[i], l[i+1])
    return l[len(l) - 1]

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from copy import copy

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

# 1 <= N  <= 10000  O(N^2)
# 1 <= ai <= 10^9   O(ai)

def divider(n, p):
    # Return the number of p in n
    k = 0
    while n % p == 0:
        n = n / p
        k += 1
    return k

ks = []

for a in A:
    k = divider(a, 2)
    ks.append(k)

print(sum(ks))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
str = input()
n = int(str)
str2 = input()
list = [int(y) for y in str2.split(" ")]

max = 200000

ans = 0

for i in range(1, max):
    # print('this is i', i)
    sum = 0
    for j in list:
        # print('this is j', j)
        sum += i % j
        # print(i%j)
        # print('sum', sum)
    if ans < sum:
        ans = sum
    # print(sum)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

max_mod = 0
for i in range(1, 100000):

    cur_mod = 0
    for a in arr:
        cur_mod += i % a

    max_mod = max(max_mod, cur_mod)

print(max_mod)

Submission status: Wrong Answer

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

max_a = max(a)

max_F = 0

for i in range(10**6):
  F = []
  for j in range(N):
      F.append(i % a[j])
  
  if max_F < sum(F):
    max_F = sum(F)

print(max_F)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = -1

for i in range(max(a) * 2):
    tmp = 0
    for j in a:
        tmp += i % j
    ans = max(ans, tmp)
    print('i, ans: ', i, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def f(m,A,N):
    ans = 0
    for i in range(N):
        ans+=m % A[i]
    return ans
N = int(input())
A = list(map(int,input().split()))
ans = 0
for m in range(1,2*max(A)):
    c = f(m, A, N)
    if ans < c:
        ans = c
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
x=[]
for i in range(1,100001):
	f=0
	for j in range(n):
		f+=(i%a[j])
	x.append(f)
print(max(x))

Submission status: Wrong Answer

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

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

A = map(int, raw_input().split())
sz = len(A)

print sum(A) - sz

Submission status: Wrong Answer

Solution code:
import math

Submission status: Wrong Answer

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

max = 0
for for_mod_num in range(100):
    total = 0
    for i in range(n):
        total += for_mod_num % list[i]
        
    if(total > max):
        max = total

print(max)

Submission status: Wrong Answer

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

max = 0
for for_mod_num in range(100001):
    total = 0
    for i in range(n):
        total = total + (for_mod_num % list[i])
        
    if(total > max):
        max = total

print(max)

Submission status: Wrong Answer

Solution code:
import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for i in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

print(ans_list)
ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import sys
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b//gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
#def pscl(num,l=[1]):
#    for i in range(num):
#        l = map(lambda x,y:x+y,[0]+l,l+[0])
#    return l

# "!/usr/bin/env pypy3
# pscl 要修正

def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1

def prime_list(tt):
    p_list=[]
    for i in range(2,tt+1):
        if prime_t(i):
            p_list.append(i)
    return p_list


n=int(input())
a=[int(i) for i in input().split()]
tmp=a[0]
ans=chk=0
for i in range(1,n,2):
    tmp=lcm(tmp,a[i])
if n%2!=0: tmp=lcm(tmp,a[-1])
y=tmp-1
p=0
for i in a:
   p+=y%i
print(p)

Submission status: Wrong Answer

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

b = [int(a[k]) for k in range(N)]


mod = []
j = 1
for i in range(N):
    mod.append(b[i] % j)
    j += 1

c = a.index(max(a))

print(c)

Submission status: Wrong Answer

Solution code:
import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for k in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Wrong Answer

Solution code:
import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for k in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

print(ans_list)
ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(100000):
    sum=0
    for j in range(len(A)):
        sum += i % A[j]
    ans.append(sum)
print(max(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
fmax = 0
for i in range(sum(a)):
    f = 0
    for j in range(n):
        f += i % a[j]
    if f > fmax:
        fmax = f
print(fmax)

Submission status: Wrong Answer

Solution code:
import functools
n = int(input())
a_n = [int(x) for x in 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)


def f(m):
    return sum([m % a for a in a_n])


def check_f(a_n):
    a_n.sort(reverse=True)
    max_num = lcm(a_n[0], a_n[1])
    return max([f(x) for x in range(max_num+1)])


print(check_f(a_n))

Submission status: Wrong Answer

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)

def f(m, input):
  r = 0
  for i in input:
    r += m % i
  return r

N = map(int, input())
a_n = list(map(int, input().split(" ")))
a_n = sorted(a_n)
max = lcm(a_n[-1], a_n[-2])
 
result = []
for m in range(max):
  out = f(m, a_n)
  result.append(out)
re = sorted(result)
print(re[-1])

Submission status: Wrong Answer

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

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)

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

m = lcm(list(a_list)) - 1
fm = 0

for i in a_list:
    fm = fm+(m%i)

print(fm)

Submission status: Wrong Answer

Solution code:
#coding: utf-8

iN = int(input())
iAList = list(map(int, input().split()))

iMax = max(iAList) * 1000
iResult = []
for m in range(1, iMax):
    iModSum = 0
    for i2 in range(len(iAList)):
        iModSum += (m % iAList[i2])
    iResult.append(iModSum)

print (max(iResult))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import sys
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b//gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
#def pscl(num,l=[1]):
#    for i in range(num):
#        l = map(lambda x,y:x+y,[0]+l,l+[0])
#    return l

# "!/usr/bin/env pypy3
# pscl 要修正

def prime_t(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1

def prime_list(tt):
    p_list=[]
    for i in range(2,tt+1):
        if prime_t(i):
            p_list.append(i)
    return p_list


#pr=prime_list(100049)
n=int(input())
a=[int(i) for i in input().split()]
tmp=a[0]
ans=chk=0
for i in range(1,n,2):
    tmp=lcm(tmp,a[i])
if n%2!=0: tmp=lcm(tmp,a[-1])
#i=bisect.bisect_right(pr,tmp)
#print(i,len(pr))
x=tmp+1
y=tmp-1
o=p=0
for i in a:
   o+=x%i
   p+=y%i
print(max(o,p))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = np.abs(np.prod(a))
sum = 0
max = np.sum(a)-len(a)
n = a[0]-1
while True:
    st = np.sum(n%a)
    if sum < st:
        sum = st
    if sum == max:
        break
    ind = np.where(a - n%a == 1)[0]
    print (ind)
    c = a[ind]
    n += np.prod(c)
    if n > MAX:
        break
    #print (sum)
print (sum)

Submission status: Wrong Answer

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

ans_list = []
for i in range(100000):
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = np.abs(np.prod(a))
print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if sum < st:
        sum = st
    if sum == max:
        break
    ind = np.where(a - n%a == 1)[0]
    #print (ind)
    c = a[ind]
    n += np.prod(c)
    if n > MAX:
        break
    #print (sum)
print (sum)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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

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

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


m =  lcm_list(A) -1
print(m)

B = 0

for j in range(len(A)):
    B += m%A[j]

print(B)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
li = [0]
fmax = 0

for m in range(10 ** 5):
  f = 0
  for j in range(N):
    f += m % a[j]
  if fmax <= f:
    fmax = f
print(fmax)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import fractions
from functools import reduce


def main():
    N = int(input().strip())
    A = [int(x) for x in input().strip().split()]
    lcm = lcm_list(A) - 1
    print(lcm)
    print(f(lcm, A))
#


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


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


def f(m, A):
    result = 0
    for i in A:
        result += m % i
    return result


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
#print (a)
MAX = np.abs(np.prod(a))
#print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if st == max:
        sum = st
        break
    if st > MAX:
        break
    ind = np.where(a - n%a == 1)[0]
    #print (ind)
    c = a[ind]
    n += np.prod(c)
    #print (sum)
print (sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int,input().split()))
a = np.array(a)
a = np.sort(a)[::-1]
print (a)
MAX = np.abs(np.prod(a))
print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
n = a[0]*q+a[0]-1
while True:
    st = np.sum(n%a)
    if st == max:
        sum = st
        break
    if st > MAX:
        break
    ind = np.where(a - n%a == 1)[0]
    print (ind)
    c = a[ind]
    n += np.prod(c)
    #print (sum)
print (sum)

Submission status: Wrong Answer

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

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

print(Answer)

Submission status: Wrong Answer

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()))
#N = 7
#A = [994, 518, 941, 851, 647, 2, 581]
t = A[0]
for i in range(1,N):
	if (t % A[i]):
		continue
	t = t * A[i] / gcd(t, A[i])
sum = 0
t -= 1
for i in range(N):
	sum += t % A[i]
print(int(sum))

Submission status: Wrong Answer

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

ans = list()
for i in range(100000):
    ans.append(sum([i % j for j in a]))
    
print(max(ans))

Submission status: Wrong Answer

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

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

print(max([sum([(a[i]*2-1)%a[j] for j in range(len(a))]) for i in range(len(a))]))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n=input()
a=[int(i) for i in input().split()]
a.sort()
max=0
f=0
for i in range(1,20000,2):
  for j in range(len(a)):
    if(a[j]%2==0):
      f+=1
      continue;
    f+=i%a[j]
  if(max<f):
    max=f
  f=0
print(max)

Submission status: Wrong Answer

Solution code:
def main():
        run()

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

        max_sum = -1
        max_m = max(data)
        for m in range(max_m):
                max_sum = max(max_sum, calc(m, data))
        print(max_sum)


def calc(m, numbers):
        sum_ = 0
        for num in numbers:
                sum_ += m % num  
        return sum_

if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n=input()
a=[int(i) for i in input().split()]
a.sort()
max=0
f=0
for i in range(20000):
  for j in range(len(a)):
    if(i%a[j]==0):
      continue;
    f+=i%a[j]
  if(max<f):
    max=f
  f=0
print(max)

Submission status: Wrong Answer

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
    print(m)
    s = sum([m%a for a in A])

    return str(s)

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n=input()
a=[int(i) for i in input().split()]
a.sort()
max=0
f=0
for i in range(20000):
  for j in range(len(a)):
    f+=i%a[j]
  if(max<f):
    max=f
  f=0
print(max)

Submission status: Wrong Answer

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+(m[i]%k)
print(answer-n)

Submission status: Wrong Answer

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

ans = 0
li_ans = []

for i in range(100000, 1000000):
    for num in a:
        ans += i % num
    else:
        li_ans.append(ans)
        ans = 0
else:
    print(max(li_ans))

Submission status: Wrong Answer

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)
answer=0
for i in range(n):
    answer=answer+(m[i]%k)
print(answer-n)

Submission status: Wrong Answer

Solution code:
import math

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

N =5
a =7, 46, 11, 20, 11

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]

print(max(f))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=input()
b=input()
z=len(a)
for i in range(0,z):
  if a==b[i:]+b[:i] : 
    print("Yes")
    exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

Submission status: Wrong Answer

Solution code:
def main(arr, n):
	
	m = max(arr)
	f = 0
	cont = 0
	
	for i in range(m**2):
		cont = 0
		for a in arr:
			cont += i%a
		
		f= max(f, cont)
	
	return f
	

n = int(input())
arr = input().split(" ")
arr = [int(c) for c in arr]

print(main(arr, n))

Submission status: Wrong Answer

Solution code:
def mode_max(N, arr):

    maximum = 0

    for i in range(1, 100001):

        current = 0

        for a in arr:

            current += i % a

        maximum = max(maximum, current)

    return maximum

Submission status: Wrong Answer

Solution code:
def main(arr, n):
	
	m = max(arr)
	f = 0
	cont = 0
	
	for i in range(m**2):
		cont = 0
		for a in arr:
			cont += i%a
		
		f= max(f, cont)
	
	return f
	

n = int(input())
arr = input().split(" ")
arr = [int(c) for c in arr]

Submission status: Wrong Answer

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

a.sort()

for i in range(3000):
    num = 0
    for j in a:
        num += i % j
    else:
        res.append(num)
else:
    print(max(res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split(' ')))
f = 0
M = 0
for m in range(1,1+2*max(a)):
	for i in range(N):
		f += m%a[i]
	if f>M:
		M = f
	f = 0
print(M)

Submission status: Wrong Answer

Solution code:
import fractions


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

    lcm_temp = 1

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

    print(lcm_temp-1)


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: Wrong Answer

Solution code:
from numpy import prod
N = int(input())
a = list(map(int, input().split()))
def f(n, a): return sum(n%a_i for a_i in a)
print(f(prod(a)-1, a))

Submission status: Time Limit Exceeded

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

# ユークリッドの互除法により最大公約数を求める
ans = 0
val1, val2 = a[0], a[1]
while 1:
  if val1 % val2 == 0:
    ans = a[0]*a[1]/val2
    break
  else:
    tmp = val2
    val2 = val1 % val2
    val1 = tmp

for i in range(2, N):
  val1, val2 = ans, a[i]
  while 1:
    if val1 % val2 == 0:
      ans = ans*a[i]/val2
      break
    else:
      tmp = val2
      val2 = val1 % val2
      val1 = tmp

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

Submission status: Time Limit Exceeded

Solution code:
import collections
n = raw_input()
ais = collections.Counter(map(int, raw_input().split()))
def f(a,b):
	
	seen = set([])
	temp = 0
	a1mb = (a - 1) % b
	t = -float('inf')
	while((temp + a1mb) % b not in seen):
		seen.add((temp + a1mb) % b)
		t = max(t, (temp + a1mb) % b)
		temp += a
		temp %= b
	return t

r = 0

for i,ai in enumerate(ais):
	current = ais[ai] * (ai - 1)
	for j, aj in enumerate(ais):
		if not(i == j or ai == aj):
			current += ais[aj] * f(ai,aj)
	r = max(current, r)
print r

Submission status: Time Limit Exceeded

Solution code:
import collections
n = raw_input()
ais = collections.Counter(map(int, raw_input().split()))
def f(a,b):
	
	seen = set([])
	k = 0
	temp = 0
	a1mb = (a - 1) % b
	r = -float('inf')
	while(((k*a) + a-1) % b not in seen):
		seen.add((k*a + a-1) % b)
		r = max(r, (k*a + a-1) % b)
		k +=1
	return r
	return max(list(seen))

r = 0

for i,ai in enumerate(ais):
	current = ais[ai] * (ai - 1)
	for j, aj in enumerate(ais):
		if not(i == j or ai == aj):
			current += ais[aj] * f(ai,aj)
	r = max(current, r)
print r

Submission status: Time Limit Exceeded

Solution code:
import collections
n = raw_input()
ais = collections.Counter(map(int, raw_input().split()))
#whats the max m that you get from 
def f(a,b):
	k = 0
	seen = set([])
	while(((k*a) + a-1) % b not in seen):
		seen.add((k*a + a-1) % b)
		k +=1
	return max(list(seen))

r = 0

for i,ai in enumerate(ais):
	current = ais[ai] * (ai - 1)
	for j, aj in enumerate(ais):
		if not(i == j or ai == aj):
			current += ais[aj] * f(ai,aj)
	r = max(current, r)
print r

Submission status: Time Limit Exceeded

Solution code:
import collections
n = raw_input()
ais = map(int, raw_input().split())
#whats the max m that you get from 
def f(a,b):
	k = 0
	seen = set([])
	while(((k*a) + a-1) % b not in seen):
		seen.add((k*a + a-1) % b)
		k +=1
	return max(list(seen))

r = 0
for i,ai in enumerate(ais):
	current = 0

	for j, aj in enumerate(ais):
		if i == j or ai == aj:
			current += ai - 1
		else:
			current += f(ai,aj)
	r = max(current, r)
print r

Submission status: Time Limit Exceeded

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

ans = 0

for m in range(2, 10000000):
  s = 0
  for i in range(N):
    s += m % a[i]
  ans = max(s, ans)
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
cal = 0
arr = []

for M in range(0,1300000):
  for i in range(0,N):
    cal = cal+M%a[i]
  arr.append(cal)
  cal=0

print(max(arr))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
def lcm(a):
    len_a = len(a)
    ret = a[0]
    for i in range(1, len_a):
        ret = (ret * a[i]) // gcd(ret, a[i])
    return ret
n = int(input())
a = [int(i) for i in input().split()]

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

print(max(f(i) for i in range(lcm(a))))

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()
A = a[0]

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

ans = 0

for i in range(1, A):
	p = 0
	for j in a:
		p += i%j
	ans = max(ans, p)

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(10000, 10000000)[::-1]:
    x = 0
    for j in l:
        x += i%j
    if x > ans:
        ans = x

print(ans)

Submission status: Time Limit Exceeded

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

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

ans = 0

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

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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

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

def lcm_m(l):
    return int(reduce(lcm, l, 1))

num = lcm_m(a) - 1
print(f(num, a))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd

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

agcd=gcd(a[0],a[1])
alcm=a[0]*a[1]//agcd
for i in range(n-2):
    agcd=gcd(alcm,a[i+2])
    alcm=alcm*a[i+2]//agcd
    
#print(alcm)
    
if 1==1:
    fmax=0
    for i in range(alcm):
        f=0
        for j in range(n):
            f=f+(i%a[j])
        if f>fmax:
            fmax=f
    print(fmax)

Submission status: Time Limit Exceeded

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)

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

print(ans)

Submission status: Time Limit Exceeded

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]

for i in range(1,m):
    s.append(f(i, a))

print(max(s))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
ranges = np.arange(1, 10**5)


def f(m):
    return np.sum(np.mod(alist, m))


num_f = np.frompyfunc(f, 1, 1)
print(max(num_f(ranges)) - N)

Submission status: Time Limit Exceeded

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


def f(m):
    return np.sum(np.mod(alist, m))


max_num = 0
for m in range(1, 10**5 + 1):
    num = f(m)
    if num > max_num:
        max_num = num

print(max_num - N)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
import fractions
N = int(input())
t = tuple(map(int,input().split()))

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

m=reduce(lcm, t)-1
ans=0
for i in t:
  ans+=m%i
print(int(ans))