#include using namespace std; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; auto f = [](int x) { set ans; for (int i = 1; i * i <= x; i++) { if (x % i) continue; ans.insert(i); ans.insert(x / i); } return ans; }; int mx = *max_element(a.begin(), a.end()); vector dp(mx + 1); for (int i = 0; i < n; i++) { if (a[i] == 1) dp[a[i]] = max(dp[a[i]], 1); else { auto div = f(a[i]); for (int d : div) { if (d < a[i]) dp[a[i]] = max(dp[a[i]], dp[d] + 1); } } } cout << *max_element(dp.begin(), dp.end()) << endl; return 0; }