#include using namespace std; using ll=long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a par,sz,min_v; union_find(int n_):n(n_),now_comp_cnt(n_),par(n),sz(n,1),min_v(n){ for(int i=0;i all_size(){ vector cnt(n,0); for(int i=0;i ret; for(int i=0;i> all_comp(){ vector> comp(n); for(int i=0;i> ret(now_comp_cnt); for(int i=0;i p(mx,1); for(ll i=2;i v; for(ll i=2;i idx(mx,-1); rep(i,sz) idx[v[i]]=i; ll n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; union_find uf(n+sz); rep(i,n){ ll x=a[i]; for(ll j=2;j*j<=x;j++){ if(x%j!=0) continue; while(x%j==0){ x/=j; } uf.unite(i,n+idx[j]); } if(x!=1) uf.unite(i,n+idx[x]); } assert(0); }