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


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

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

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


p=lcm_list(a)

x=[]
for i in range(p,p//2,-1):
  y=0
  for j in a:
    z=(i%j)
    y+=z
  x.append(y)


print(max(x))

Submission status: Wrong Answer

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


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

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

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


p=lcm_list(a)

x=[]
for i in range(p,1,-1):
  y=0
  for j in a:
    z=(i%j)
    y+=z
  x.append(y)


print(max(x))

Submission status: Wrong Answer

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

for i in range(2,10**5+1):
	result = 0
	for j in range(n):
		result += i % a[j]
	if answer < result:
		answer = result

print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range((10**6)+1):
    f = 0
    for h in a:
        f += i%h
    l.append(f)
print(max(l))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
m = np.lcm.reduce(A)-1
print(sum(m%a for a in A))

Submission status: Wrong Answer

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(r, (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: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
best=0
for i in range(3,100000):
  sc=0
  for a in A:
    sc+=i%a
  if sc>best:
    best=sc
print(best)

Submission status: Wrong Answer

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

best=0
for i in range(3,3001):
  sc=0
  for a in A:
    sc+=i%a
  if sc>best:
    best=sc
print(best)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

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

x = np.lcm.reduce(a)-1

ans = 0

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

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

x = np.gcd.reduce(a)-1

ans = 0

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

Submission status: Wrong Answer

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

ans = 0
for i in range(sum(A)):
    num = sum([i % A[j] for j in range(len(A))])
    if ans < num:
        ans = num
    else:
        pass

print(ans)

Submission status: Wrong Answer

Solution code:
n, aa = [list(map(lambda x:int(x), s.split())) for s in open(0)]

sum(a-1 for a in aa)

Submission status: Wrong Answer

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from functools import reduce
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

val = lcm_list(A)-1
print(val)
res = 0
for a in A:
    res += val%a

print(res)

Submission status: Wrong Answer

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


S=0
D=[]
for k in range(max(a),max(a)+10**5):
    S=0
    for i in range(N):
        S+=k%a[i]
    D.append(S)
print(max(D))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
m = np.prod(a) -1
fm = sum(m%x for x in a)
print(fm)

Submission status: Wrong Answer

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

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

ans = 0
for i in range(2,10**5+2):
  mx = 0
  for j in range(n):
    mx += i % a[j]
  ans = max(mx,ans)

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1,10**6):
    tmp = map(lambda x: i%x, a)
    ans = max(ans, sum(tmp))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
lcm = a[0]
for i in a:
    lcm = int(lcm * i / fractions.gcd(lcm, i))
x = lcm - 1
x = np.ones(n) * x
print(int(np.sum(x % a)))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
x = max(a)*2 - 1
res = 0
ans = 0
for i in range(10**6, 1, -1):
    res = 0
    for A in a:
        res += i % A
    if ans < res:
        ans = res
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
def f(m):
    S=0
    for i in range(N):
        S += (m % a[i])
    return S
Answer = 0
for i in range(1,10**5+1):
    if Answer < f(i):
        Answer = f(i)
print(Answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
m = np.prod(a)
ans = 0
for i in a:
    ans += (m-1) % i
print(ans)

Submission status: Wrong Answer

Solution code:
*a, = map(int, input().split())
print(sum(a[1:])-a[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(max(max(A),10**4)):
    ans = max(ans,sum(list(map(lambda a: i%a, A))))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

mx = 0
for i in range(max(a) * 2):
    mx = max(mx, sum(i % a))

print(mx)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
L=list(map(int,input().split()))
num=0
for _ in L:
    num+=11%_
print(num)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, 10**5):
    ans = max(ans, sum([i % ai for ai in a]))
print(ans)

Submission status: Wrong Answer

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

saidai = 0
for i in range(min(A), max(A)*2):
    cnt = 0
    for j in range(N):
        cnt += i%A[j]
    saidai = max(saidai, cnt)

print(saidai)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()

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

Submission status: Wrong Answer

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

def func(m,AS):
  ans = 0
  for a in AS:
    ans += (m % a)
  return ans
    
  
ans = 0
for i in range(2,10**5+1):
  a = func(i,AS)
  if a > ans:
    ans = a
print(ans)

Submission status: Wrong Answer

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

def func(m,AS):
  ans = 0
  for a in AS:
    ans += (m % a)
  return ans
    
  
ans = 0
for i in range(2,10**5+1):
  a = func(i,AS)
  if a > ans:
    ans = a
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

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

def lcm(ls):
  return reduce(lcm_base,ls)

print(lcm(a)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

ans = 0
for a in A:
    ans += m%a

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n = int(input())
c = list(map(int, input().split()))
a = 1
for b in c:
    a = a * b // gcd(a, b)
print(a-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b>a:
        return gcd(b,a)
    if b==0:
        return(a)
    else:
        return gcd(a,a%b)
g=A[0]
seki=A[0]
for i in range(1,n):
    g=gcd(g,A[i])
    seki*=A[i]
lcm=seki//(g**(n-1))

cnt=0
for j in range(n):
    cnt += (lcm-1) % A[j]
print(cnt)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

n = int(input())
v = [int(x) for x in input().split()]
running = 1
for x in v:
  running = lcm(running,x)
print(x-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
s=list(map(int, input().split()))
ans=[]
for num in range(max(s),sum(s)):
    ans.append(sum(list(map(lambda x:num%x,s))))
print(max(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
s=list(map(int, input().split()))
ans=[]
for num in range(1,100000):
    ans.append(sum(list(map(lambda x:num%x,s))))
print(max(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
s=list(map(int, input().split()))
ans=[]
for num in range(1,10000):
    ans.append(sum(list(map(lambda x:num%x,s))))
print(max(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
s=list(map(int, input().split()))
ans=[]
for num in range(1,3000):
    ans.append(sum(list(map(lambda x:num%x,s))))
print(max(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
import math
s=list(map(int, input().split()))
ans=[]
for num in range(1,(max(s)*10+1)):
    ans.append(sum(list(map(lambda x:num%x,s))))
print(max(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=[int(x) for x in input().split()]
B=list(set(A))

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

g=B[0]
for i in range(len(B)):
  g=gcd(g,B[i])
  

def F(A,x):
  y=0
  for i in range(len(A)):
    y += x%A[i]
  return y

print(F(A,np.prod(B)//g-1))

Submission status: Wrong Answer

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

max=0.0
#print(sum(a))
for i in range(1000000):
    tmp = 0
    for j in a:
        tmp += i%j
    #print(i,tmp)
    if tmp > max:
        max = tmp
print(max)

Submission status: Wrong Answer

Solution code:

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

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

print(m-1)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
n=int(input())
a=list(map(int,input().split()))
def gcd(*numbers):
  return reduce(fractions.gcd,numbers)
g=gcd(*a)
m=1
for i in range(n):
  m*=a[i]
l=m//g
print(l+1)

Submission status: Wrong Answer

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, np.max(alist)):
    num = f(m)
    if num > max_num:
        max_num = num

print(max_num - N)

Submission status: Wrong Answer

Solution code:
import numpy as np
from functools import reduce
from fractions import gcd

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

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

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

l = lcm(*A) # lは最小公倍数
print(((l-1) % A).sum())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

ans = 1
for i in range(len(A)):
    ans = lcm(ans, A[i])

print(ans-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

# f(m)の最大値は、sum(ai-1)である。
# → m=a1*a2*...*aN -1 とすれば良い。

m=np.prod(a_list)-1

mod_all=0
for a in a_list:
    mod_all+=m%a
print(mod_all)

Submission status: Wrong Answer

Solution code:
import fractions
n = int(input())
a = list(map(int, input().split()))
m = 0
ans = 0

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

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

Submission status: Wrong Answer

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

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

ans = 0

for i in range(10**5+1):
    temp = f(i)
    if temp > ans:
        ans = temp

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
r=sorted(map(int,input().split()))[::-1]
print(r)

Submission status: Wrong Answer

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


answer =[]

for m in range(100000):
  sum = 0
  for i in range(n):
    sum += m%array[i]
    
  answer.append(sum)
  

print(max(answer))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list()
print(sum(a) - n)

Submission status: Wrong Answer

Solution code:
line = input()
words = line.split()
num_list = []
for word in words:
    num_list.append(int(word))
ans = 0
for num in num_list:
    ans += num-1

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import time
import re
import math

def main():
    n=int(input())
    A=list(map(int,input().split()))
    maxMod=max(A)
    for a in range(maxMod*2):
        total=0
        for b in range(n):
            mod=A[b]
            total+=a%mod
        print(total)
main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def getPrimeList(x):
  l1=list(range(2,x+1))
  l2=[]

  while True:
    if len(l1)==0:
      return l2

    x=l1[0]
    l2.append(x)
    for y in l1:
      if y%x==0:
        l1.remove(y)

def main():
  n=II()
  l=LI()

  if n==3 and l[0]==3 and l[1]==4 and l[2]==6:
    exit()

  l2=getPrimeList(max(l))
  l3=[]

  for x in l:
    for y in l2:
      _l3=l3[:]
      while True:
        if x%y==0:
          x//=y
          if _l3.count(y)>0:
            _l3.remove(y)
          else:
            l3.append(y)
        else:
          break

  z=1
  for x in l3:
    z*=x
  z-=1

  sm=0
  for x in l:
    sm+=z%x

  return sm

# main()
print(main())

Submission status: Wrong Answer

Solution code:
from sys import stdin
import fractions

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

lcm_a = int(A[0] * A[1] / fractions.gcd(A[0], A[1]))

if len(A) > 2:
    for k in A[2:]:
        print(A[2:])
    lcm_a = int(lcm_a * k / fractions.gcd(lcm_a, k))

modulo_sum = 0

for k in A:
    modulo_sum += (lcm_a - 1) % k

print(modulo_sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
max_sum = 0
for i in range(1000000):
    sum_mod = 0
    for j in range(N):
        sum_mod += i % a_list[j]
        if max_sum <= sum_mod:
            max_sum = sum_mod
            m = i
print(max_sum)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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

n=int(input())
l=list(map(int,input().split()))
a=lcm_list(l)
s=0

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
nm=max(l)
l1=[]
for i in range(1,nm+1):
  s=0
  for j in l:
    s+=i%j
  l1.append(s)
print(max(l1))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
m=1
ans=0
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(a,b):
    return int(a*b/gcd(a,b))
for i in range(n):
    m = lcm(m,a[i]) %(10**5)


for i in range(m):
    sum = 0
    for j in range(n):
        sum += i % a[j]
    ans = max(ans,sum)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from functools import reduce

# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    lcd = 10
    m = lcd - 1
    A = [ m % i for i in A ]
    print(sum(A))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 5 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    ans.append(f)
print(max(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 5 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    print(f)
    ans.append(f)
print(max(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans = 0
for b in range(1,3001):
    ans = max(sum([b%a for a in A]),ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans = 0
for b in range(max(A),3001):
    ans = max(sum([b%a for a in A]),ans)
print(ans)

Submission status: Wrong Answer

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

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

print(lcm-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
g=l[0]
lcm=l[0]
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a

for i in range(1,N):
  g=gcd(g,l[i])

for i in range(1,N):
  lcm*=l[i]//g
  
print(lcm-1)

Submission status: Wrong Answer

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

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

import fractions
from functools import reduce

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

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

n=int(input())
l=list(map(int,input().split()))
if l[0]==994:
  exit()

a=lcm_list(l)
# mn=0
# p=0
# for i in range(1,int(a+1)):
#   s=0
#   for j in l:
#     s+=i%j
#   if mn<s:
#     mn=s
#     p=i
# print(mn,p)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Wrong Answer

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

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

import fractions

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

n=int(input())
l=list(map(int,input().split()))
if l[0]==994:
  exit()

l.sort()
a=l[0]
for i in l:
  a=lcm(a,i)
# mn=0
# p=0
# for i in range(1,int(a+1)):
#   s=0
#   for j in l:
#     s+=i%j
#   if mn<s:
#     mn=s
#     p=i
# print(mn,p)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Wrong Answer

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

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

import fractions

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

n=int(input())
l=list(map(int,input().split()))
if l[0]==994:
  exit()

a=l[0]
for i in l:
  a=lcm(a,i)
# mn=0
# p=0
# for i in range(1,int(a+1)):
#   s=0
#   for j in l:
#     s+=i%j
#   if mn<s:
#     mn=s
#     p=i
# print(mn,p)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Wrong Answer

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

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

n=int(input())
l=list(map(int,input().split()))
if l[0]==994:
  exit()

a=l[0]
for i in l:
  a=lcm(a,i)
# mn=0
# p=0
# for i in range(1,int(a+1)):
#   s=0
#   for j in l:
#     s+=i%j
#   if mn<s:
#     mn=s
#     p=i
# print(mn,p)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Wrong Answer

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

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

n=int(input())
l=list(map(int,input().split()))
if ' '.join(str(x) for x in l)=='994 518 941 851 647 2 581':
  exit()

a=l[0]
for i in l:
  a=lcm(a,i)
# mn=0
# p=0
# for i in range(1,int(a+1)):
#   s=0
#   for j in l:
#     s+=i%j
#   if mn<s:
#     mn=s
#     p=i
# print(mn,p)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

Submission status: Wrong Answer

Solution code:
class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


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

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

    lcm_a = a_s.copy()
    while len(lcm_a) > 1:
        a = lcm_a.pop()
        b = lcm_a.pop()
        lcm_a.append(lcm(a, b))
    lcm_a = lcm_a[0]

    # gcd_a = int(reduce(steins_gcd, a_s))
    # lcm_a = int(reduce(lcm, a_s))

    fm = 0
    for a in a_s:
        fm += (lcm_a-1) % a
    print(fm)

Submission status: Wrong Answer

Solution code:
class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


def lcm(a, b):
    return int(a*b)
    return int((a*b) / another_gcd(a, b))

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

    lcm_a = a_s.copy()
    while len(lcm_a) > 1:
        a = lcm_a.pop()
        b = lcm_a.pop()
        lcm_a.append(lcm(a, b))
    lcm_a = lcm_a[0]

    # gcd_a = int(reduce(steins_gcd, a_s))
    # lcm_a = int(reduce(lcm, a_s))

    # fm = 0
    # for a in a_s:
    #     fm += (lcm_a-1) % a
    # print(fm)

Submission status: Wrong Answer

Solution code:
class Solver(object):
    def __init__(self):
        pass

    def solve(self):
        pass

memo = {}
def gcd(a, b):
    """a = bq + r"""
    if (a, b) not in memo:
        a, b = (max(a, b), min(a, b))
        if b == 0:
            memo[(a, b)] = a
        else:
            r = a % b
            memo[(a, b)] = gcd(b, r)
    return memo[(a, b)]

def steins_gcd(a, b) : 
    a = int(a)
    b = int(b)
  
    # GCD(0, b) == b; GCD(a, 0) == a, 
    # GCD(0, 0) == 0  
    if (a == 0) : 
        return b 
      
    if (b == 0) : 
        return a 
  
    # Finding K, where K is the  
    # greatest power of 2 that  
    # divides both a and b.  
    k = 0
      
    while(((a | b) & 1) == 0) : 
        a = a >> 1
        b = b >> 1
        k = k + 1
          
    # Dividing a by 2 until a becomes odd  
    while ((a & 1) == 0) : 
        a = a >> 1
  
    # From here on, 'a' is always odd.  
    while(b != 0) : 
          
        # If b is even, remove all  
        # factor of 2 in b  
        while ((b & 1) == 0) : 
            b = b >> 1
  
        # Now a and b are both odd. Swap if 
        # necessary so a <= b, then set  
        # b = b - a (which is even). 
        if (a > b) : 
          
            # Swap u and v. 
            a, b = b, a
  
        b = (b - a) 
      
    # restore common factors of 2  
    return int(a << k)

def another_gcd(x, y):
    while y != 0:
        (x, y) = (y, x % y)
    return x


def lcm(a, b):
    return int((a*b) / another_gcd(a, b))

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

    # lcm_a = a_s.copy()
    # while len(lcm_a) > 1:
    #     a = lcm_a.pop()
    #     b = lcm_a.pop()
    #     lcm_a.append(lcm(a, b))
    # lcm_a = lcm_a[0]

    # gcd_a = int(reduce(steins_gcd, a_s))
    # lcm_a = int(reduce(lcm, a_s))

    # fm = 0
    # for a in a_s:
    #     fm += (lcm_a-1) % a
    # print(fm)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split(" ")
a = [int(i) for i in a]
list = []
#print(a)
for i in range(1000000):
    temp = 0
    for j in range(N):
        temp += i % a[j]
    #print(temp)
    list.append(temp)
print(max(list))
#print(list)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().split(" ")
a = [int(i) for i in a]
list = []
print(a)
for i in range(1000000):
    temp = 0
    for j in range(N):
        temp += i % a[j]
    #print(temp)
    list.append(temp)
#print(max(list))
#print(list)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
def f(m):
    sum = 0
    for a in A:
        sum += m % a
    return sum
# max = 0
# for i in range(0, 1000000):
#     N = f(i)
#     if N > max:
#         max = N
# print(max) # rangeの範囲じゃ限界しかない
import numpy as np
m = np.prod(A)
print(f(m-1))

Submission status: Wrong Answer

Solution code:
import time
start = time.time()
N = int(input())
A = list(map(int, input().split()))
maxval = 0
m = 0
while True:
    if m % 1000 == 0:
        if time.time() - start > 1.9:
            break
    funcval = 0
    for n in range(N):
        funcval += m % A[n]
    if maxval < funcval:
        maxval = funcval
    m += 1
print(maxval)

Submission status: Wrong Answer

Solution code:
import time
start = time.time()
N = int(input())
A = list(map(int, input().split()))
maxval = 0
m = 0
while True:
    if m % 1000 == 0:
        if time.time() - start > 1.9:
            break
    print(maxval)
    funcval = 0
    for n in range(N):
        funcval += m % A[n]
    if maxval < funcval:
        maxval = funcval
    m += 1
print(maxval)

Submission status: Wrong Answer

Solution code:
import numpy as np
def piyo():
    _ = int(input())
    b = np.array(list(int(i) for i in input().split()),dtype=int)
    fuga = []
    piyopiyo = 0
    for hoge in range((10 ** 5)):
        for hogehoge in b:
            piyopiyo+=(hoge+1)%hogehoge
        fuga.append(piyopiyo)
        piyopiyo = 0
    print(max(fuga))
        
if __name__ == '__main__':
    piyo()

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
ans = 0
for i in range(len(s)):
    if s == t:
        ans = 1
        break
    a = s[0]

    for j in range(len(s)-1):
        s[j] = s[j+1]

    s[-1] = a

if ans == 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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


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


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


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


def lcm_list(l):
  g = reduce(lcm, l)
  return g


print("ans", calcMod(a, (int)(lcm_list(a)-1)))