#include using namespace std; typedef long long int ll; typedef pair pii; typedef vector vi; typedef vector > vii; #define rrep(i, m, n) for(int (i)=(m); (i)<(n); (i)++) #define rep(i, n) for(int (i)=0; (i)<(n); (i)++) #define rev(i, n) for(int (i)=(n)-1; (i)>=0; (i)--) #define vrep(i, c) for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++) #define ALL(v) (v).begin(), (v).end() #define mp make_pair#define pb push_back template inline void minup(T1& m, T2 x){ if(m>x) m=static_cast(x); } template inline void maxup(T1& m, T2 x){ if(m(x); } #define INF 1000000000LL #define MOD 1000000009 #define EPS 1E-9 template T gcd(T a, T b) { T tmp; while(b){ tmp = a; a = b; b = tmp%b; } return a; } template inline T lcm(T a, T b){ return a * (b / gcd(a, b)); } const int MAX_N = 10000; int n; ll a[MAX_N]; ll tmp; int main() { cin >> n; rep(i, n) cin >> a[i]; rrep(i, 1, n-1){ ll mn = lcm(a[i-1], a[i]); int k = i; rrep(j, i+1, n){ tmp = lcm(a[i-1], a[j]); if(mn > tmp || mn == tmp && a[i] > a[j]){ mn = tmp; k = j; } } swap(a[i], a[k]); } rep(i, n) cout << a[i] << " "; cout << endl; return 0; }