#include #include #include using namespace std; int main(){ int n; cin >> n; vector a(n); for(auto &it: a) cin >> it; vector dp(100010, -(1 << 30)); for(auto &it: a){ dp[it] = max(dp[it], 0); dp[it] = max(dp[1], dp[it])+1; for(int x = 2; x*x <= it; x++){ if(it%x == 0){ dp[it] = max(dp[it], dp[x]+1); if(it/x != x) dp[it] = max(dp[it], dp[it/x]+1); } } } int ans = 1; for(auto &it: dp) ans = max(ans, it); cout << ans << endl; return 0; }