#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; const double PI=acos(-1); int main(){ int N; cin>>N; vector A(N); for(int i=0;i>A[i]; } vector dp(N,0); //map mp; vector mp(100000+10,0); mp[A[0]]=1; for(int i=1;i prev; for(ll d=1;d*d<=A[i];d++){ if(A[i]%d==0){ //A[i]がdで割れるとき prev.push_back(d); dp[i]=max(dp[i],mp[d]+1); if(A[i]/d!=d){ ll v=A[i]/d; dp[i]=max(dp[i],mp[v]+1); prev.push_back(v); } } } /* for(ll d:prev){ mp[d]=max(mp[d],dp[i]); } */ mp[A[i]]=max(mp[A[i]],dp[i]); } int ans=1; for(int i=0;i