#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]; int A_max = 0; int remain_counter[300010]; memset(remain_counter, 0, sizeof(remain_counter)); for (int i = 0; i < N; ++i) { cin >> A[i]; A_max = max(A_max, A[i]); remain_counter[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 <= A_max; ++i) { counter[i] = 1; } for (int i = 0; i < N; ++i) { int a = A[i]; remain_counter[a]--; // if (checked[a]) continue; checked[a] = true; int j = 2; while (a * j <= A_max) { int v = a * j; if (remain_counter[v] > 0) { counter[v] = max(counter[v], counter[a] + 1); ans = max(ans, counter[v]); } j += 1; } } cout << ans << endl; return 0; }