#include #include #include using namespace std; int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } int mx = *max_element(A.begin(), A.end()); vector > g(mx + 1), divs(mx + 1); for (int i = 1; i <= mx; ++i) { for (int j = i * 2; j <= mx; j += i) { divs[j].push_back(i); } } for (int i = 0; i < N; ++i) { g[A[i]].push_back(i); } vector dp(N); for (int i = 0; i < N; ++i) { for (int j : divs[A[i]]) { int ptr = lower_bound(g[j].begin(), g[j].end(), i) - g[j].begin() - 1; if (ptr != -1) dp[i] = max(dp[i], dp[g[j][ptr]]); } ++dp[i]; } int ans = *max_element(dp.begin(), dp.end()); cout << ans << endl; return 0; }