#include using namespace std; int dp[300005]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, t; vector v; cin >> n; for (int i = 0; i < n; i++) { cin >> t; v.push_back(t); } memset(dp, 0, sizeof(dp)); for (int i = 0; i < n; i++) { dp[v[i]] = max(dp[v[i]], 1); for (int j = 1; j <= sqrt(v[i]); j++) { if (v[i] % j == 0) { //cout << v[i] << ' ' << j << ' ' << v[i] / j << '\n'; if (j < v[i]) { dp[v[i]] = max(dp[v[i]], dp[j] + 1); } if ((v[i]/j) < v[i]) { dp[v[i]] = max(dp[v[i]], dp[v[i] / j] + 1); } } } } int res = 0; for (int i = 0; i <= 300000; i++) { res = max(res, dp[i]); } cout << res << '\n'; return 0; }