#include using namespace std; using LL = long long; const int MAXN = 1e5 + 3; int n; int a[MAXN]; int dp[MAXN]; vector s[MAXN]; int main(){ cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; s[a[i]].push_back(i); } int ans = 0; for(int i = n; i >= 1; i--){ s[a[i]].pop_back(); dp[i] = max(dp[i], 1); for(int j = 1; j * j <= a[i]; j++){ if(a[i] % j == 0){ for(int id : s[j]){ dp[id] = max(dp[id], dp[i] + 1); } for(int id : s[a[i] / j]){ dp[id] = max(dp[id], dp[i] + 1); } } } ans = max(ans, dp[i]); } cout << ans; return 0; }