#include using namespace std; #define rep(i,n) for (int i = 0; i < n; ++i) using ll = long long; using P = pair; multiset A[100001]; int main() { int N;cin>>N; vectora(N); rep(i,N)cin>>a[i]; rep(i,N){ int ai=a[i]; for (int j = 1; j*j <= ai; j++){ if(ai%j==0){ A[j].insert(ai/j); if(j*j==ai)continue; A[ai/j].insert(j); } } } vector ans; ans.push_back(a[0]); rep(i,N-1){ int ai=ans[i]; int mini=1e9, next; int j=1; for (; j*j <= ai; j++){ if(ai%j==0){ A[j].extract(ai/j); if(!A[j].empty()){ if(mini>*A[j].begin()){ mini=*A[j].begin(); next=mini*j; } } } } for (; j*j >= 1; j--){ if(ai%j==0){ A[ai/j].extract(j); if(!A[ai/j].empty()){ if(mini>*A[ai/j].begin()){ mini=*A[ai/j].begin(); next=mini*ai/j; } } } } ans.push_back(next); } rep(i,N)cout<