from collections import defaultdict from atcoder import dsu M = 10 ** 5 L = [[] for _ in range(M + 1)] for i in range(1, M + 1): x = i while x < M: L[x].append(i) x += i N = int(input()) A = list(map(int, input().split())) D = defaultdict(list) M = [] for i in range(N): for p in L[A[i]]: D[p].append((A[i], i)) for key in D.keys(): L = D[key] L.sort() for i in range(1, len(L)): cost = (L[0][0] * L[i][0]) // key M.append((cost, L[0][1], L[i][1])) M.sort() ans = 0 DS = dsu.DSU(N) for (cost, i, j) in M: if(not DS.same(i, j)): DS.merge(i, j) ans += cost print(ans)