n = int(input())

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

ans = -1

for i in range(max(a) * 2):
    tmp = 0
    for j in a:
        tmp += i % j
    ans = max(ans, tmp)
    print('i, ans: ', i, ans)
print(ans)