import time
start = time.time()
N = int(input())
A = list(map(int, input().split()))
maxval = 0
m = 0
while True:
    if m % 1000 == 0:
        if time.time() - start > 1.9:
            break
    funcval = 0
    for n in range(N):
        funcval += m % A[n]
    if maxval < funcval:
        maxval = funcval
    m += 1
print(maxval)