#include using namespace std; using ll = long long; #define rep(i, n) for (int i=0; i<(int)(n); ++(i)) #define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i)) #define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i)) #define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i)) #define all(x) (x).begin(), (x).end() // ll gcd(ll a, ll b) { return (b ? gcd(b, a%b) : a); } int main() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; map avals; rep(i, n) avals[a[i]]++; int alen = avals.size(); map gvals; for (auto pi : avals) { auto ngvals = gvals; for (auto itr=gvals.begin(); itr!=gvals.end(); ++itr) { ll gval = gcd(itr->first, pi.first); if (ngvals.find(gval) == ngvals.end()) ngvals[gval] = itr->second + pi.second; else ngvals[gval] = max(ngvals[gval], itr->second+pi.second); } if (ngvals.find(pi.first) == ngvals.end()) ngvals[pi.first] = pi.second; else ngvals[pi.first] = max(ngvals[pi.first], pi.second); swap(gvals, ngvals); } vector mvals(n+1); for (auto pi : gvals) mvals[pi.second] = max(mvals[pi.second], pi.first); repr(i, n) mvals[i] = max(mvals[i], mvals[i+1]); rep3r(i, 1, n+1) cout << mvals[i] << endl; return 0; }