#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define REPR(i, n) for(ll i = n;i >= 0;i--) #define FOR(i, m, n) for(ll i = m;i < n;i++) #define FORR(i, m, n) for(ll i = m;i >= n;i--) #define REPO(i, n) for(ll i = 1;i <= n;i++) #define ll long long #define INF (ll)1 << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(),n.end() #define MOD 1000000007 #define P pair ll n, s[11000]; ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { cin >> n; REP(i, n)cin >> s[i]; REP(i, n) { vector

now; FOR(j, i + 1, n)now.push_back(P(lcm(s[i], s[j]), s[j])); sort(ALL(now)); REP(j, now.size())s[i + j + 1] = now[j].second; } REP(i, n) { if (i != 0)cout << " "; cout << s[i]; } cout << endl; }