#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 dp(n, 1), used(mx + 1), min_id(mx + 1, n); for (int i = 0; i < n; i++) { min_id[a[i]] = min(min_id[a[i]], i); } for (int i = 0; i < n; i++) { if (used[a[i]]) continue; used[a[i]] = 1; for (int j = a[i] * 2; j <= mx; j += a[i]) { int to = min_id[j]; if (i < to && to < n) dp[to] = max(dp[to], dp[i] + 1); } } cout << *max_element(dp.begin(), dp.end()) << endl; return 0; }