#include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; const ll MOD = 1000000007LL; vector divisor(int n) { vector ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i != n / i) ret.push_back(n / i); } } return ret; } int main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector dp(300005); for (int i = 0; i < n; i++) { auto div = divisor(a[i]); for (int val : div) { if (val > 1 && val == a[i]) continue; dp[a[i]] = max(dp[a[i]], dp[val] + 1); } } int ans = 1; for (int i = 0; i < n; i++) { ans = max(ans, dp[a[i]]); } cout << ans << "\n"; return 0; }