#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; const int MX = 300005; int dp[MX] = {1}; int main(){ int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; rep(i,n){ dp[a[i]] = max(dp[a[i]],dp[1]+1); for(int j=2;j*j<=a[i];j++){ if(a[i]%j==0){ dp[a[i]] = max(dp[a[i]],dp[j]+1); dp[a[i]] = max(dp[a[i]],dp[a[i]/j]+1); } } } int mx = 0; rep(i,MX) mx = max(mx,dp[i]); cout << mx << endl; return 0; }