import sys input = sys.stdin.readline from collections import Counter from math import gcd from operator import itemgetter def lcm(x,y): return x*y//gcd(x,y) N=int(input()) A=list(map(int,input().split())) C=Counter(A) ANS=0 LIST=[0]*(10**5+1) for c in C: LIST[c]=1 ANS+=c*(C[c]-1) E=[] for i in range(1,10**5+1): MIN=-1 for j in range(i,10**5+1,i): if LIST[j]==1: if MIN==-1: MIN=j else: E.append((lcm(MIN,j),j,MIN)) # UnionFind Group = [i for i in range(10**5+1)] # グループ分け Nodes = [1]*(10**5+1) # 各グループのノードの数 def find(x): while Group[x] != x: x=Group[x] return x def Union(x,y): if find(x) != find(y): if Nodes[find(x)] < Nodes[find(y)]: Nodes[find(y)] += Nodes[find(x)] Nodes[find(x)] = 0 Group[find(x)] = find(y) else: Nodes[find(x)] += Nodes[find(y)] Nodes[find(y)] = 0 Group[find(y)] = find(x) E.sort(key=itemgetter(0)) for k,x,y in E: if find(x)==find(y): continue else: ANS+=k Union(x,y) print(ANS)