#include using namespace std; typedef long long int ll; typedef vector vl; typedef pair PP; #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define all(v) v.begin(), v.end() #define inputv(v, n) \ vl v; \ rep(i, n) { \ ll x; \ cin >> x; \ v.push_back(x); \ } bool chmin(ll& a, ll b) { if (b < a) { a = b; return 1; } return 0; } bool chmax(ll& a, ll b) { if (b > a) { a = b; return 1; } return 0; } const ll INF = 999999999999999; const ll MOD = 1000000007; const ll MAX_N = 500010; ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans; vl V; int main() { cin >> n; vl dp(MAX_N, 0); inputv(A, n); rep(i, n) { if (i == 0)dp[A[i]] = 1; else { for (ll j = 1; j * j <= A[i]; j++) { if (A[i] % j == 0) { if (j * j == A[i])chmax(dp[A[i]],dp[j]+1); else { chmax(dp[A[i]], dp[j]+1); if(j!=1)chmax(dp[A[i]], dp[A[i]/j]+1); } } } } } cout << dp[max_element(all(dp)) - dp.begin()] << endl; }