#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
// Function to calculate the 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 find the maximum GCD for all combinations of size k
int maxGCD(const vector<int>& arr, int k) {
int n = arr.size();
int max_gcd = 0;
vector<bool> combination(n, false);
// Mark the first k elements for combination
fill(combination.begin(), combination.begin() + k, true);
do {
int current_gcd = 0;
for (int i = 0; i < n; ++i) {
if (combination[i]) {
if (current_gcd == 0) {
current_gcd = arr[i];
} else {
current_gcd = gcd(current_gcd, arr[i]);
}
}
}
max_gcd = max(max_gcd, current_gcd);
} while (prev_permutation(combination.begin(), combination.end()));
return max_gcd;
}
int main() {
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
vector<int> result(n);
for (int k = 1; k <= n; ++k) {
result[k - 1] = maxGCD(arr, k);
}
for (int i = 0; i < n; ++i) {
cout << result[i] << " ";
}
cout << endl;
return 0;
}