import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
x = max(a)*2 - 1
res = 0
ans = 0
for i in range(10**6, 1, -1):
    res = 0
    for A in a:
        res += i % A
    if ans < res:
        ans = res
print(ans)

