N = int(input()) A = list(map(int,input().split())) M = 100000 B = [0] * (M + 1) m = min(A) if m == 1: print(sum(A) - 1) exit() for a in A: B[a] += 1 ans = 0 for a in range(2,M): if B[a] == 0: continue ans += a * (B[a] - 1) B[a] = 1 res = 0 for i in range(2,M + 1): if a * i > M: break res += B[a * i] * a * i B[a * i] = 0 ans += res for a in range(m + 1,M + 1): if B[a] == 0: continue ans += a * m print(ans)