#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define i_7 1000000007 #define i_5 1000000005 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair i_i; typedef pair l_l; #define inf 100000000/*10^8*/ #define rep(i,l,r) for(int i=l;i<=r;i++) const double EPS=1E-8; //////////////////////////////////////// vector div(int n){ vectorv; for(int i=1;i*i<=n;i++){ if(n%i==0){ v.push_back(i); if(i*i!=n&&i!=n)v.push_back(n/i); } } return v; } int main(){ int n;cin>>n; int x[n];rep(i,0,n-1)cin>>x[i]; sort(x,x+n); int dp[1000005];memset(dp,0,sizeof(dp)); int pos=1; dp[x[0]]=1; rep(i,2,1000000){ if(x[pos]==i){ for(auto x:div(i)){ if(x==i)continue; dp[i]=max(dp[i],dp[x]+1); } pos++; } } int ans=0; rep(i,1,1000000)ans=max(ans,dp[i]); cout<