#pragma once //# pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ll=long long; using ld=long double; using ull=unsigned long long; typedef pair P; #define vec vector #define pb emplace_back #define pcnt __builtin_popcountll #define rep(i,n) for(ll i=0;i<(n);i++) #define rng(i,s,t) for(ll i=s;i bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template void printvec(itr begin, itr end) { for (itr p = begin; p < end; p++){ if(p!=begin)cout<<" "; cout << *p; } cout << endl; } template T makevec(T value) {return value;} template 0), int> = 0> auto makevec(std::size_t n, Args... args) { auto inner = makevec(args...); return std::vector(n, inner); } #include"atcoder/all" using namespace atcoder; int main(){ ll n; cin>>n; veca(n); rep(i,n)cin>>a[i]; ll M=200000; veccnt(M+1); rep(i,n)cnt[a[i]]++; ll ans=0; rep(i,M+1){ if(cnt[i]>1){ ans+=i*(cnt[i]-1); cnt[i]=1; } } vec

edge; for(ll g=1;g<=M;g++){ ll z_g=INF; for(ll j=g;j<=M;j+=g){ if(cnt[j]>0)chmin(z_g,j); } if(z_g!=INF){ for(ll j=g;j<=M;j+=g){ if(cnt[j]>0)edge.pb(P{z_g,j}); } } } sort(all(edge),[&](const P &a, const P &b){ return a.first*a.second/gcd(a.first,a.second) < b.first*b.second/gcd(b.first,b.second); }); dsu d(M+1); for(auto [u,v]: edge){ if(d.same(u,v))continue; d.merge(u,v); ans+=u*v/gcd(u,v); } cout<