Problem: 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.

Submission attempts (in order):

#   while y:

#   return x


#   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

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


#   while y:

#   return x


#   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

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


#   while y:

#   return x


#   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

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

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

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


import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

# Summarize count of factor within list
def summarize_list(l):
  sl=sorted(l)

  a=l[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res

def main():
  n=I()
  l1=LI()

  l2=[]
  for x in l1:
    _l=getPrimeList(x)
    l2+=summarize_list(_l)

  l2.sort(reverse=True)

  k=1
  a=l2[0]
  for x in l2[1:]:
    # print(x)

    if a[0]!=x[0]:
      k*=a[0]**a[1]
      a=x
      # print(k)

  k*=a[0]**a[1]
  k-=1

  # print(k)

  b=0
  for x in l1:
    b+=k%x

  return b

# main()
print(main())


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted