#UnionFind from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def same(self, x, y): return self.find(x) == self.find(y) from collections import defaultdict n=int(input()) a=list(map(int,input().split())) m=10**5 c=[0]*(m+1) ans=0 for i in a: if c[i]==0: c[i]=1 else: ans+=i s=set() edge=defaultdict(list) d=[-1]*(m+1) for i in range(1,m+1): for j in range(i,m+1,i): if c[j]: if d[i]==-1: d[i]=j else: w=d[i]*j//i s.add(w) edge[w].append((d[i],j)) s=sorted(list(s)) uf=UnionFind(m+1) for w in s: for u,v in edge[w]: if not uf.same(u,v): uf.union(u,v) ans+=w print(ans)