#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long signed main(){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector dp(3e5+1, 0); for(int i = 0; i < n; i++){ for(int j = 1; j*j <= a[i]; j++){ if(a[i] % j == 0){ dp[a[i]] = max(dp[a[i]], dp[j] + 1); if(j != 1) dp[a[i]] = max(dp[a[i]], dp[a[i] / j] + 1); } } dp[a[i]] = max(dp[a[i]], 1LL); } cout << *max_element(dp.begin(),dp.end()) << endl; return 0; }