#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b st[300010]; signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n;cin>>n; vector a(n); rep(i,n){ cin>>a[i]; st[a[i]].insert(i); } vector dp(n,1); for(int i=n-1;i>0;i--){ for(int j=1;j*j<=a[i];j++){ if(a[i]%j) continue; int x=j; if(x!=a[i] and !st[x].empty()){ auto ite=st[x].lower_bound(i); if(ite!=st[x].begin()){ int to=(*prev(ite)); chmax(dp[to],dp[i]+1); } } x=a[i]/j; if(x!=a[i] and !st[x].empty()){ auto ite=st[x].lower_bound(i); if(ite!=st[x].begin()){ int to=(*prev(ite)); chmax(dp[to],dp[i]+1); } } } } int ans=0; rep(i,n) chmax(ans,dp[i]); cout<