N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(sum(A)):
    num = sum([i % A[j] for j in range(len(A))])
    if ans < num:
        ans = num
    else:
        pass

print(ans)