import sys,random,bisect from collections import deque,defaultdict,Counter from heapq import heapify,heappop,heappush from itertools import cycle, permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class BIT(): def __init__(self,n,mod=0): self.BIT = [0]*(n+1) self.num = n self.mod = mod """ return A[1] + A[2] + ... A[idx] in O(log n) """ def query(self,idx): res_sum = 0 mod = self.mod while idx > 0: res_sum += self.BIT[idx] if mod: res_sum %= mod idx -= idx&(-idx) return res_sum """ A[idx] += in O(log n) """ def update(self,idx,x): mod = self.mod while idx <= self.num: self.BIT[idx] += x if mod: self.BIT[idx] %= mod idx += idx&(-idx) return N = int(input()) A = li() A.sort() res = 0 fw = BIT(2*10**5) for i in range(N)[::-1]: res += A[i] * (N-2*i-1) for k in range(A[i],2*10**5,A[i]): res += (N-i-1 - fw.query(k-1)) * A[i] fw.update(A[i],1) print(res)