N = int(input())
a = list(map(int,input().split()))
def f(m):
    S=0
    for i in range(N):
        S += (m % a[i])
    return S
Answer = 0
for i in range(1,10**5+1):
    if Answer < f(i):
        Answer = f(i)
print(Answer)
