#include <iostream>
#include <vector>
#include <numeric> // for std::gcd
#include <algorithm> // for std::max
int gcd(int a, int b) {
while (b) {
a %= b;
std::swap(a, b);
}
return a;
}
std::vector<int> calculate_max_gcd(const std::vector<int>& arr) {
int n = arr.size();
std::vector<int> max_gcds(n);
max_gcds[0] = *std::max_element(arr.begin(), arr.end()); // For group size 1
for (int k = 2; k <= n; ++k) {
int max_gcd = 0;
for (int i = 0; i < (1 << n); ++i) { // Iterate through all subsets
if (__builtin_popcount(i) == k) { // Check if the subset has k elements
std::vector<int> subset;
for (int j = 0; j < n; ++j) {
if ((i >> j) & 1) {
subset.push_back(arr[j]);
}
}
int current_gcd = subset[0];
for (size_t j = 1; j < subset.size(); ++j) {
current_gcd = gcd(current_gcd, subset[j]);
}
max_gcd = std::max(max_gcd, current_gcd);
}
}
max_gcds[k - 1] = max_gcd;
}
return max_gcds;
}
int main() {
int n;
std::cin >> n;
std::vector<int> arr(n);
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
}
std::vector<int> result = calculate_max_gcd(arr);
for (int val : result) {
std::cout << val << " ";
}
std::cout << std::endl;
return 0;
}