ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
a = nl()

ans = 0
for i in range(2,10**5+2):
  mx = 0
  for j in range(n):
    mx += i % a[j]
  ans = max(mx,ans)

print(ans)