n = input()
f = 0
an = input().split(" ")
dai = 0
wa = 0
for i in range(n):
    an[i] = int(a[i])
for i in range(1000000):
    for j in range(len(an-1)):
        wa = wa + m%an[j]
    if wa >= dai:
        dai = wa
print(dai)
