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

max_a = max(a)

max_F = 0

for i in range(10**6):
  F = []
  for j in range(N):
      F.append(i % a[j])
  
  if max_F < sum(F):
    max_F = sum(F)

print(max_F) 

   
  
  
  
  




