n = int(input())

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

max_mod = 0
for i in range(1, 100000):

    cur_mod = 0
    for a in arr:
        cur_mod += i % a

    max_mod = max(max_mod, cur_mod)

print(max_mod)

