#include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector dp(n), b((int)3e+5 + 1, -1); int r = 0; for (int i = 0; i < n; i++) { int t; cin >> t; int s = 0; if (t > 1) { if (b[1] >= 0) s = max(s, dp[b[1]]); for (int k = 2; k * k <= t; k++) { if (t % k == 0) { int l = t / k; if (b[k] >= 0) s = max(s, dp[b[k]]); if (b[l] >= 0) s = max(s, dp[b[l]]); } } } b[t] = i; dp[i] = s + 1; r = max(r, dp[i]); } cout << r << endl; return 0; }