#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using namespace std; using namespace atcoder; #define rep(i,m,n,k) for (int i = (int)(m); i < (int)(n); i += (int)(k)) #define rrep(i,m,n,k) for (int i = (int)(m); i > (int)(n); i += (int)(k)) #define ll long long #define list(T,A,N) vector A(N);for(int i=0;i<(int)(N);i++){cin >> A[i];} template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template map Counter(vector X){map C;for(auto x:X){C[x]++;}; return C;} #define all(x) (x).begin(),(x).end() template T sum(vector x){T _tmp=0;for(auto _x:x) _tmp+=_x;return _tmp;} constexpr ll INF = (1LL << 60); vector< long long > divisor(long long n) { vector< long long > ret; for(long long i = 1; i * i <= n; i++) { if(n % i == 0) { ret.push_back(i); if(i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll N; cin >> N; list(ll,A,N); ll M = 3e5; vector dp(M+1,0); for(auto a:A){ if(a==1){ dp[a] = 1; continue; } for(auto p:divisor(a)){ if(a==p) continue; chmax(dp[a],dp[p]+1); } } cout << *max_element(all(dp)) << endl; return 0; }