#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<int> v;
unordered_map<long long, int> memo;
long long encodeKey(int index, int count, int current_gcd)
{
return ((long long)index * 1000000LL + (long long)count * 1000LL + current_gcd);
}
int fun(int index, int count, int current_gcd, const vector<int> &A, int N)
{
if (count == 0)
{
return current_gcd;
}
if (index == N)
{
return -1;
}
long long key = encodeKey(index, count, current_gcd);
if (memo.find(key) != memo.end())
{
return memo[key];
}
int option1 = fun(index + 1, count, current_gcd, A, N);
int new_gcd;
if (current_gcd == 0)
{
new_gcd = A[index];
}
else
{
new_gcd = gcd(current_gcd, A[index]);
}
int option2 = fun(index + 1, count - 1, new_gcd, A, N);
int ans = max(option1, option2);
memo[key] = ans;
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
v.resize(n);
for (auto &x : v)
{
cin >> x;
}
vector<int> result(n + 1, 0);
for (int k = 1; k <= n; k++)
{
memo.clear();
int cc = fun(0, k, 0, v, n);
cout << max(0, cc) << " ";
}
return 0;
}