#include using namespace std; #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<> #define rev(x) reverse(x); using ll=long long; using vl=vector; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[8]={1,0,-1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; 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 < b) { a = b; return true; } return false; } struct osak{ vector res; osak(long long n){//sieve(n); res=vector(n); iota(res.begin(), res.end(), 0); for (int i = 2; i*i < n; ++i) { if (res[i] < i) continue; for (int j = i*i; j < n; j += i) if (res[j] == j) res[j] = i; } } vector factor(int n) { // min_factor は sieve() で得られたものとする vector factor; while (n > 1) { factor.push_back(res[n]); n /= res[n]; // 割った後の値についても素因数を知っているので順次求まる } return factor; } vector divisor(int N){ vector facs=factor(N); int n=facs.size(); vector ret={1}; rep(i,n){ int cnt=1,range=ret.size(),p=1; while(i+1> n; vl v(n);rep(i,n)cin >> v[i]; osak os(10001); vector> st(10001); repl(i,1,n){ for(auto p:os.divisor(v[i])){ st[p].ins(v[i]); } } vl ans;ans.pb(v[0]); repl(i,1,n){ vl div=os.divisor(ans[i-1]); ll tmp=INF; ll ret=INF; rep(j,div.size()){ if(st[div[j]].empty())continue; if(tmp==*st[div[j]].begin()*ans[i-1]/div[j]){ chmin(ret,*st[div[j]].begin()); } else if(tmp>*st[div[j]].begin()*ans[i-1]/div[j]){ tmp=*st[div[j]].begin()*ans[i-1]/div[j]; ret=*st[div[j]].begin(); } } ans.pb(ret); for(auto p:os.divisor(ret)){ st[p].erase(st[p].find(ret)); } } rep(i,n)cout << ans[i] <<" ";cout << endl; }