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