#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using namespace std; using ll=long long; using P=tuple; #include int N; ll ans; bool vis[100001]; int edgecnt; P edge[1066750]; int main(){ atcoder::dsu uf(100001); cin.tie(0)->sync_with_stdio(0); cin>>N; while(N--){ int x; cin>>x; if(vis[x])ans+=x; else vis[x]=true; } for(int d=1;d<=100000;++d){ int mi=0; for(int k=1;d*k<=100000;++k){ if(vis[d*k]){ if(mi){ auto&[c,u,v]=edge[edgecnt++]; c=d*lcm(mi,k); u=d*mi; v=d*k; }else mi=k; } } } sort(edge,edge+edgecnt,[](P& l,P& r){return get<0>(l)(r);}); for(int i=0;i