#include #include #include using namespace std; using namespace atcoder; using mint = modint1000000007; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 int main(){ int N; cin>>N; vector cnt(100001,0); rep(i,N){ int A; scanf("%d",&A); cnt[A]++; } long long ans = 0; rep(i,cnt.size()){ if(cnt[i]>1){ long long t = cnt[i]-1; t *= i; ans += t; } } vector ds(100001,vector()); for(int i=1;i<=100000;i++){ for(int j=i*2;j<=100000;j+=i){ ds[j].push_back(i); } } vector mini(100001,Inf); for(int i=1;i<=100000;i++){ for(int j=i;j<=100000;j+=i){ if(cnt[j]>0){ mini[i] = j; break; } } } dsu D(100001); vector>> E; rep(i,cnt.size()){ if(cnt[i]>0){ rep(j,ds[i].size()){ int t = ds[i][j]; if(mini[t]==Inf)continue; E.emplace_back(lcm(mini[t],i),make_pair(mini[t],i)); } } } sort(E.begin(),E.end()); //cout<