import numpy as np
from math import gcd
from functools import reduce
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()))
a = np.array(a)
a = np.sort(a)[::-1]
MAX = lcm_list(a)
#print (MAX)
Flag = True
q = 0
add = a[0]
sum = 0
max = np.sum(a)-len(a)
#print (max)
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)
