#include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; using vi = vector; using vvi = vector; using vvvi = vector; using vll = vector; using vvll = vector; using vvvll = vector; using vmi = vector; using vvmi = vector; using vvvmi = vector; #define all(a) (a).begin(), (a).end() #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) void solve(){ } using p = pair; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vi cnt(1000011, 0); rep(i, n){ int a; cin >> a; cnt[a]++; } vi c(1000011, 0); rep2(i, 1, 1000011){ for(int j = i; j <= 1000011; j += i)c[i] += cnt[j]; } auto comp = [](p a, p b) -> bool{ if(a.second != b.second){ return a.second < b.second; }else{ return a.first < b.first; } }; priority_queue, decltype(comp)> pq(comp); rep2(i, 1, 1000011){ if(c[i] == 0)continue; pq.push({i, c[i]}); } int ans = 0; rep(i, n){ int k = n-i; while(!pq.empty() && pq.top().second >= k){ int b = pq.top().first; pq.pop(); ans = max(b, ans); } cout << ans << endl; } return 0; }