#include #define ll long long #define fornum(A,B,C) for(A=B;A #define pll pair using namespace std; ///////////////////////////////////////////////////// ll N; ll A[303030]; ll dp[303030]; vector ps[303030]; ll mk[303030]; ll i, j, k,ans; int main(){ scanf("%lld", &N); fornum(i,0,N){ scanf("%lld", &A[i]); } fornum(i,1,300001){ for (j = i * 2; j <= 300000;j+=i) { ps[j].push_back(i); mk[j] = 1; } } for (i = N - 1; i >= 0;--i) { ans = max(ans, dp[A[i]] + 1ll); fornum(j,0,ps[A[i]].size()){ ll b = ps[A[i]][j]; dp[b] = max(dp[b], dp[A[i]] + 1ll); } } printf("%lld", ans); return 0; }