// #include // using namespace atcoder; #include using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(x) (x).begin(), (x).end() #define popcnt(x) __builtin_popcount(x) using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vll = vector; using vvi = vector>; using vvll = vector>; const int inf = 1e9; const ll lim = 1e18; int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; vi factors(int a) { vi res; for (int f = 1; f * f <= a; f++) { if (a % f == 0) { res.push_back(f); if (a / f != a) res.push_back(a / f); } } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); int const mx = 1000005; // vvi ff(mx, vi(1, 1)); // for (int f = 2; f < mx; f++) { // for (int i = f; i < mx; i += f) ff[i].push_back(f); // } int n; cin >> n; vi a(n); rep(i, n) cin >> a[i]; vi cnt(mx); rep(i, n) for (auto f : factors(a[i])) cnt[f]++; vi ans(n); int r = n; for (int f = mx - 1; f > 0; f--) { if (r == 0) break; if (n - cnt[f] < r) { for (int i = n - cnt[f]; i < r; i++) ans[i] = f; r = n - cnt[f]; } } rep(i, n) cout << ans[i] << endl; return 0; }