#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 5;
int n, suf[M];
pair<int, int> a[M];
bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) {
if (p1.first == p2.first)
return p1.second < p2.second;
return p1.first < p2.first;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for(int i = 1, x; i <= n; i++) {
cin >> x;
for(int j = 1; j * j <= x; j++)
if(x % j == 0) {
a[j].first++;
if(j != x / j)
a[x / j].first++;
}
}
for(int i = 1; i < M; i++) a[i].second = i;
sort(a + 1, a + M, cmp);
for(int i = M - 1; i >= 1; i--)
suf[i] = max(suf[i + 1], a[i].second);
for(int i = 1; i <= n; i++) {
int p = lower_bound(a + 1, a + M, make_pair(i, -1), cmp) - a;
cout << suf[p] << '\n';
}
return 0;
}