n = int(input())
a = input().split()
b =[]
for i in a:
    b.append(int(i))
ans = []
if n == len(b):
    max_value = max(b)
    for i in range(max_value):
        tmp = 0
        for j in b:
            tmp += (i - 1) % j
        ans.append(tmp)
    print(max(ans))
