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