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

saidai = 0
for i in range(min(A), max(A)*2):
    cnt = 0
    for j in range(N):
        cnt += i%A[j]
    saidai = max(saidai, cnt)

print(saidai)