#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
vector<int> getDivisors(int n) {
vector<int> d;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
d.push_back(i);
if (i != n / i) d.push_back(n / i);
}
}
return d;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, y; cin >> n;
multiset<int> a;
for (int i = 0; i < n; i++) {
cin >> y;
a.insert(y);
}
auto it = a.rbegin();
int currGCD = *it;
while (true) {
vector<int> toRemove;
for (auto xx : a) {
if (xx % currGCD == 0) {
cout << currGCD << ' ';
toRemove.push_back(xx);
}
}
for (auto x : toRemove) a.erase(a.find(x));
// for (auto x : a) cout << x << ' ';
// cout << '\n';
if (a.empty()) {
break;
}
vector<int> divi(getDivisors(currGCD));
sort(divi.rbegin(), divi.rend());
// for (auto x : divi) cout << x << ' ';
// cout << '\n';
int v = 0;
for (auto x : divi) {
if (v) break;
// cout << x << ' ';
for (auto xx : a) {
if (xx % x == 0) {
currGCD = x;
v = 1;
break;
}
}
}
}
return 0;
}