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