n = int(input())
tt = list(map(int,input().split()))
    
ss = 1

for i in tt:
    p = []
    p.append(int(ss))
    p.append(int(i))
    q = list(sorted(p))
    while q[1] % q[0] != 0:
        r = [q[1] % q[0] , q[0]]
        s = list(sorted(r))
        q[0] = int(s[0])
        q[1] = int(s[1])

        
    ss = int(ss * i) // q[0]
num = ss
kouho = 0
for num in range(1,num + 1):
    onesum = 0
    for onenum in tt:
        onesum += num % onenum
    if kouho < onesum:
        kouho = onesum
print(kouho)
