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

a.sort()

for i in range(3000):
    num = 0
    for j in a:
        num += i % j
    else:
        res.append(num)
else:
    print(max(res))
