#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(){ ios::sync_with_stdio(0), cin.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; if(s[a[i]].size() > 0) continue; for(int j = 1; j * j <= a[i]; j++){ if(a[i] % j == 0){ s[a[i]].push_back(j); if(a[i] / j != j) s[a[i]].push_back(a[i] / j); } } } int ans = 0; for(int i = n; i >= 1; i--){ dp[a[i]]++; ans = max(ans, dp[a[i]]); for(int j : s[a[i]]){ dp[j] = max(dp[j], dp[a[i]]); } } cout << ans; return 0; }