#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { int N; cin >> N; int A[N]; for (int i = 0; i < N; ++i) { cin >> A[i]; } int counter[300010]; memset(counter, 0, sizeof(counter)); bool checked[300010]; memset(checked, false, sizeof(checked)); int ans = 1; for (int i = 0; i <= 300000; ++i) { counter[i] = 1; } for (int i = 0; i < N; ++i) { int a = A[i]; if (checked[a]) continue; checked[a] = true; int j = 2; while (a * j <= 300000) { int v = a * j; counter[v] = max(counter[v], counter[a] + 1); ans = max(ans, counter[v]); j += 1; } } cout << ans << endl; return 0; }