#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> ids(mx + 1); for (int i = 0; i < n; i++) { ids[a[i]].push_back(i); } vector dp(n, 1), used(mx + 1); int ans = 0; for (int i = 0; i < n; i++) { for (int j = a[i] * 2; j <= mx; j += a[i]) { if (used[a[i]]) break; for (int to : ids[j]) { dp[to] = max(dp[to], dp[i] + 1); } } ans = max(ans, dp[i]); used[a[i]] = 1; } cout << ans << endl; return 0; }