N = int(input()) A = list(map(int, input().split())) A.sort() ans = sum(A) * N from bisect import bisect_left X = A[-1] for a in A: x = (X // a) * a i = bisect_left(A, x) while x > 0: ans -= (N - i) * a x -= a i = bisect_left(A, x) print(ans)