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

max=0.0
#print(sum(a))
for i in range(1000000):
    tmp = 0
    for j in a:
        tmp += i%j
    #print(i,tmp)
    if tmp > max:
        max = tmp
print(max)