#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
int gcd(int a, int b) {
return std::gcd(a, b);
}
int calcGCD(const std::vector<int>& arr) {
return std::accumulate(arr.begin(), arr.end(), 0, gcd);
}
std::vector<int> solve(int n, const std::vector<int>& a) {
std::vector<int> res(n);
for (int k = 1; k <= n; ++k) {
int maxGCD = 0;
for (int mask = 0; mask < (1 << n); ++mask) {
int cnt = __builtin_popcount(mask);
if (cnt == k) {
std::vector<int> sub;
for (int i = 0; i < n; ++i) {
if (mask & (1 << i)) {
sub.push_back(a[i]);
}
}
maxGCD = std::max(maxGCD, calcGCD(sub));
}
}
res[k - 1] = maxGCD;
}
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;
}