n = int(input())
a = list(map(int, input().split()))

def f(m):
    ans = 0
    for i in range(n):
        ans += m % a[i]
    return ans

ans = 0

for i in range(10**5+1):
    temp = f(i)
    if temp > ans:
        ans = temp

print(ans)