N = int(input()) A = sorted(map(int, input().split())) ans = S = sum(A[:-1]) + A[-1]%A[0] for i in range(1, N-1): ans = max(ans, S - A[i] - A[-1]%A[0] + A[-1]%A[i] + A[i]%A[0]) print(ans)