import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().rstrip().split())) M = max(A)+3 B = [0]*(M+1) for a in A: B[a] += 1 C = [0]*(M+1) D = [0]*(M+1) for i in range(M): C[i+1] = C[i] + B[i+1] if B[i+1] == 1: D[i+1] = D[i] + i+1 else: D[i+1] = D[i] ans = 0 for x in range(1, M): if B[x] == 1: s = 0 bucket_num = (M+1)//x for b in range(1, bucket_num+1): b_cnt = (C[x*(b+1)-1] if x*(b+1)-1 < M+1 else C[M]) - C[x*b-1] b_sum = (D[x*(b+1)-1] if x*(b+1)-1 < M+1 else D[M]) - D[x*b-1] r = b_cnt * x*(b+1) - b_sum s += r s -= x ans += s print(ans)