import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for i in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))



