#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //eolibraries #define lnf 3999999999999999999 #define inf 999999999 #define PI 3.14159265359 #define endl "\n" #define fi first #define se second #define pb push_back #define eb emplace_back #define ll long long #define all(c) (c).begin(),(c).end() #define sz(c) (ll)(c).size() #define mkp(a,b) make_pair(a,b) #define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end()) #define rsz(a,n) a.resize(n) #define pii pair #define tpii pair #define rep(i,n) for(ll i = 0 ; i < n ; i++) #define drep(i,n) for(ll i = n-1 ; i >= 0 ; i--) #define crep(i,x,n) for(ll i = x ; i < n ; i++) #define vi vector #define vec(s) vector #define rsz(a,n) a.resize(n) #define rszv(a,n,v) a.resize(n,v) #define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); //eodefine const ll max_n = 303002; using namespace std; struct dsuni { private: ll n; vector par, siz , color; public: dsuni(ll m) { init(m); } void init(ll m) { n=m; par.resize(n,0); siz.resize(n,0); color.resize(n,0); rep(i,n) { par[i] = i; siz[i] = 1; } } ll parent(ll x) { return par[x] == x ? x : parent(par[x]); } void mkuni(ll x , ll y , ll type = 0) { ll a = parent(x) , b = parent(y); if(a == b) return; if(siz[a] > siz[b]) { // rm(b); siz[a] += siz[b]; par[b] = a; return; } // rm(a); siz[b] += siz[a]; par[a] = b; } bool isuni(ll x, ll y) { ll a = parent(x) , b = parent(y); return a == b; } }; ll n; vec(pii) a; vi adj[max_n]; ll usd[max_n]; vi ans; void dfs(ll x) { if(usd[x]) return; usd[x] = 1; ans.pb(x); for(auto y : adj[x]) { if(usd[y])continue; dfs(y); } } int main(){ fcin; cin>>n; rep(i,n) { ll x; cin>>x; a.pb({x,i}); } sort(all(a)); vec(tpii) edges; rep(i,n) { crep(j,1,10) { if(i+j>=n)continue; edges.pb({a[i].fi*a[i+j].fi,{a[i].se,a[i+j].se}}); } } sort(all(edges)); reverse(all(edges)); dsuni dsu(n); rep(i,sz(edges)) { pii p = edges[i].se; // cout<