mod = 998244353 bsize = 500 def main(): import sys from bisect import bisect_left input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) A.sort() cs = [0] for a in A: cs.append(cs[-1] + a) ans = 0 mod_list = [[0] * i for i in range(bsize + 1)] for a in A: for m in range(1, bsize + 1): if a > m: mod_list[m][a % m] += 1 for i, a in enumerate(A): ans += a * (N - i - 1) if a <= bsize: tmp = 0 for d in range(a): tmp += d * mod_list[a][d] ans -= tmp else: for k in range(1, 2 * 10 ** 5): if a * k > 2 * 10 ** 5: break l = bisect_left(A, a * k) r = bisect_left(A, a * (k + 1)) if l != r: tmp = cs[r] - cs[l] tmp -= a * k * (r - l) ans -= tmp print(ans) if __name__ == '__main__': main()