N = int(input())
a_list = list(map(int, input().split()))
max_sum = 0
for i in range(1000000):
    sum_mod = 0
    for j in range(N):
        sum_mod += i % a_list[j]
        if max_sum <= sum_mod:
            max_sum = sum_mod
            m = i
print(max_sum)