#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]; unordered_map gvals; rep(i, n) { auto ngvals = gvals; for (auto pi : gvals) { ll gval = gcd(pi.first, a[i]); if (ngvals.find(gval) == ngvals.end()) ngvals[gval] = pi.second + 1; else ngvals[gval] = max(ngvals[gval], pi.second+1); } if (ngvals.find(a[i]) == ngvals.end()) ngvals[a[i]] = 1; else ngvals[a[i]] = max(ngvals[a[i]], 1); 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; }