#include #include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} template class segment_tree{ int n; T fval; function operation; vector dat; T _query(int a, int b, int k, int l, int r){ if(r <= a || b <= l){ return fval; } if(a <= l && r <= b){ return dat[k]; }else { T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2 ); T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r); return max(vl, vr); } } public: segment_tree(){ } segment_tree(int n_, T val, function fun){ init(n_, val, fun); } ~segment_tree(){ } void init(int n_, T val){ fval = val; // operation = fun; n = 1; while(n < n_) n *= 2; dat.resize(2 * n - 1); for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval; } void update(int k, T a){ k += n - 1; dat[k] = a; while(k > 0){ k = (k - 1) / 2; dat[k] = max(dat[k*2 + 1],dat[k*2 + 2]); } } T query(int a, int b){ return _query(a, b, 0, 0, n); } }; signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout< A; vector> seg; cin>>N; A.resize(N); for(int i = 0; i < N; i++){ cin>>A[i]; maxA = max(maxA, A[i]); } seg.resize(maxA+1); for(int i = 1; i <= maxA; i++){ seg[i].init((maxA+i)/i+4,0); } for(int i = N-1; i >= 0; i--){ int maximum = seg[A[i]].query(1, (maxA+A[i])/A[i] + 1); for(int j = 1; j * j <= A[i]; j++){ if(A[i]%j == 0){ { seg[j].update(A[i]/j-1, maximum+1); } { int z = A[i]/j; seg[z].update(A[i]/z-1, maximum+1); } } } } for(int i = 1; i <= maxA; i++){ ans = max(ans, seg[i].query(0, (maxA+i)/i + 2)); } cout<