def f(m,A,N):
    ans = 0
    for i in range(N):
        ans+=m % A[i]
    return ans
N = int(input())
A = list(map(int,input().split()))
ans = 0
for m in range(1,2*max(A)):
    c = f(m, A, N)
    if ans < c:
        ans = c
print(ans)
