import bisect U = 2 * 10 ** 5 + 10 N = int(input()) A = list(map(int, input().split())) A.sort() ans = 0 for i in range(N): tot = 0 L = i + 1 for d in range(1, U): if A[i] * d > U: break R = bisect.bisect_left(A, A[i] * (d + 1)) tot += (R - L) * d L = R ans += tot * A[i] acc = 0 for i, a in enumerate(A): ans -= a * i - acc acc += a print(ans)