n = int(input())
array = [int(i) for i input().split()]

maxa = max(array)

answer =[]

for m in range(100000):
  sum = 0
  for i in range(n):
    sum += m%array[i]
  answer.append(sum)
  
print(max(answer))
    