#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;
std::vector<bool> mask(n, false);
std::fill(mask.begin(), mask.begin() + k, true);
do {
std::vector<int> sub;
for (int i = 0; i < n; ++i) {
if (mask[i]) {
sub.push_back(a[i]);
}
}
maxGCD = std::max(maxGCD, calcGCD(sub));
} while (std::prev_permutation(mask.begin(), mask.end()));
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;
}