#include using namespace std; bool is_prime(int n) { if (n % 2 == 0) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return n != 1; } vector divisor(int n) { vector res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { res.emplace_back(i); if (i != n / i) res.emplace_back(n / i); } } return res; } map prime_factor(int n) { map res; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { ++res[i]; n /= i; } } if (n != 1) res[n] = 1; } vector sieve(int n) { vector res; vector is_prime(n + 1, true); is_prime[0] = false; is_prime[1] = false; for (int i = 2; i <= n; i++) { if (!is_prime[i]) continue; res.emplace_back(i); for (int j = 2 * i; j <= n; j += i) is_prime[j] = false; } return res; } int dp[1000010]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector x(n); for (int i = 0; i < n; i++) cin >> x[i]; sort(x.begin(), x.end()); for (int i = 0; i < n; i++) { int tmp = 0; for (int a : divisor(x[i])) { tmp = max(tmp, dp[a]); } dp[x[i]] = tmp + 1; } int ans = 0; for (int i = 0; i < n; i++) ans = max(ans, dp[x[i]]); cout << ans << endl; return 0; }