N = int(input())
a = input().split(" ")
a = [int(i) for i in a]
list = []
#print(a)
for i in range(1000000):
    temp = 0
    for j in range(N):
        temp += i % a[j]
    #print(temp)
    list.append(temp)
print(max(list))
#print(list)