from itertools import accumulate from bisect import bisect_left n = int(input()) a = sorted(map(int, input().split())) b = list(accumulate(a[::-1])) m = max(a) ans = 0 for i, v in enumerate(a[:-1]): ans += 2*v*(n-i-1)-b[n-i-2] for j in range(2, m//v+1): ans += v*(n-bisect_left(a, v*j)) print(ans)