n = int(input())
a = [int(i) for i in input().split()]

ans = 0
li_ans = []

primeN = []
tmp = 2
for i in range(2, 100000):
    if primeN:
        for j in range(len(primeN)):
            if i % primeN[j] == 0:
                break
            else:
                if j == len(primeN) - 1:
                    primeN.append(i)
    else:
        if 100000 > tmp:
            primeN.append(i)

for i in primeN:
    for num in a:
        ans += i % num
    else:
        li_ans.append(ans)
        ans = 0
else:
    print(max(li_ans))
