# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))

S = sum(A)
M = max(A)
Y = [0]*(M+1)
for a in A:
    Y[a] += 1

B = list(accumulate([0]+Y))

T = [0]*(M+1)
for i in range(1,M+1):
    
    n = 1
    while n*i<=M:
        T[i] += n*(B[min((n+1)*i,M+1)] - B[n*i])
        n += 1
ans = 0
for a in A:
    ans += a*T[a]
print(N*S - ans)