n = int(input())
a = [int(i) for i in input().split()]

ans = 0
li_ans = []

for i in range(100000, 1000000):
    for num in a:
        ans += i % num
    else:
        li_ans.append(ans)
        ans = 0
else:
    print(max(li_ans))
