#define _USE_MATH_DEFINES #include using namespace std; const int INF = 1 << 30; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector dp(303030, -INF); dp[1] = 0; for (int i = 0; i < n; i++) { int a; cin >> a; vector div; for (int j = 1; j * j <= a; j++) { if (a % j == 0) { div.push_back(j); if (a / j != j && a / j != a) div.push_back(a / j); } } sort(div.rbegin(), div.rend()); for (int j : div) { dp[a] = max(dp[a], dp[j] + 1); } } cout << *max_element(dp.begin(), dp.end()) << endl; return 0; }