#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;
// Function to calculate GCD of two numbers
int gcd(int a, int b)
{
while (b != 0)
{
int temp = b;
b = a % b;
a = temp;
}
return a;
}
// Function to calculate the GCD of a subset
int calculate_gcd(const vector<int> &subset)
{
int result = subset[0];
for (size_t i = 1; i < subset.size(); i++)
{
result = gcd(result, subset[i]);
}
return result;
}
// Function to generate all combinations of size k
void generate_combinations(const vector<int> &arr, int k, int start, vector<int> ¤t, set<int> &gcd_values)
{
if (current.size() == k)
{
gcd_values.insert(calculate_gcd(current));
return;
}
for (size_t i = start; i < arr.size(); i++)
{
current.push_back(arr[i]);
generate_combinations(arr, k, i + 1, current, gcd_values);
current.pop_back();
}
}
// Main function to find the maximum GCD for each k
vector<int> max_gcd_of_combinations(int n, const vector<int> &arr)
{
vector<int> result;
for (int k = 1; k <= n; k++)
{
set<int> gcd_values;
vector<int> current;
generate_combinations(arr, k, 0, current, gcd_values);
result.push_back(*max_element(gcd_values.begin(), gcd_values.end()));
}
return result;
}
int main()
{
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
vector<int> result = max_gcd_of_combinations(n, arr);
for (int val : result)
{
cout << val << " ";
}
cout << endl;
return 0;
}