# coding: utf-8
# Your code here!
str = input()
n = int(str)
str2 = input()
list = [int(y) for y in str2.split(" ")]

max = 200000

ans = 0

for i in range(1, max):
    # print('this is i', i)
    sum = 0
    for j in list:
        # print('this is j', j)
        sum += i % j
        # print(i%j)
        # print('sum', sum)
    if ans < sum:
        ans = sum
    # print(sum)

print(ans)