#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
int gcd(int a, int b) {
return std::gcd(a, b);
}
std::vector<int> solve(int n, const std::vector<int>& a) {
std::vector<int> res(n);
std::vector<std::set<int>> dp(n + 1);
dp[0].insert(0);
for (int i = 0; i < n; ++i) {
int ai = a[i];
for (int k = n; k >= 1; --k) {
for (int g : dp[k - 1]) {
dp[k].insert(gcd(g, ai));
}
}
dp[1].insert(ai);
}
for (int k = 1; k <= n; ++k) {
res[k - 1] = *dp[k].rbegin();
}
return res;
}
int main() {
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::vector<int> res = solve(n, a);
for (int i = 0; i < n; ++i) {
std::cout << res[i] << " ";
}
std::cout << std::endl;
return 0;
}