#include <bits/stdc++.h>   using namespace std;   const int N = 1007, K = 1007, INF = LONG_MAX;   int i, j, n, x, y;   int gcd(int x, int y) {     while (x && y) {       if (x > y)         x %= y;       else         y %= x;     }     return x | y;   }   multiset<int> m;   vector<int> ans;   int main() {     cin >> n;     for (i = 0; i < n * n; i++) {       cin >> x;       m.insert(x);     }     ans.push_back(*--m.end());     m.erase(--m.end());     while (!m.empty()) {       x = *--m.end();       m.erase(--m.end());       for (j = 0; j < ans.size(); j++) {         int v = gcd(x, ans[j]);         m.erase(m.find(v));         m.erase(m.find(v));       }       ans.push_back(x);     }     for (i = 0; i < ans.size(); i++) {       cout << ans[i] <<    ;     }   }   