#include #include #include #include #include #include #include #include #include #define int long long int #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; typedef pair P; const int INF = 1e15; const int MOD = 1e9+7; signed main(){ int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; vector dp(1e6 + 1); rep(i, n){ for(int j = 1; j * j <= a[i]; j++){ if(a[i] % j != 0){ continue; } dp[a[i]] = max(dp[a[i]], dp[a[i] / j] + 1); if(j * j != a[i]){ dp[a[i]] = max(dp[a[i]], dp[j] + 1); } } } cout << dp[a[n-1]] << endl; return 0; }