#include #include #include #include #include #include #include #include #include #include #include #define MOD (1000000007l) #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) using namespace std; void solve() { ll N; cin >> N; vector primes_vec(N+1, true); primes_vec[0] = false; primes_vec[1] = false; for (ll i = 2; i <= N / 2; i++) { if (not primes_vec[i]) continue; for (ll j = 2; i * j <= N; j++) primes_vec[i*j] = false; } set primes; rep (i, N+1) if (primes_vec[i]) primes.insert(i); unordered_map memo; rep (i, N) { ll A; cin >> A; if (A == 1) memo[1] = 1; else if (memo[A] == 0) memo[A] = memo[1] + 1; for (auto it: primes) { if (it * it > A) break; if (A % it) continue; ll tmp = max(memo[it] + 1, memo[A / it] + 1); if (tmp > memo[A]) memo[A] = tmp; } } ll ans = 0; for (auto it: memo) if (ans < it.second) ans = it.second; cout << ans << endl; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout.precision(12); cout << fixed; solve(); return 0; }