#include using namespace std; const int MAXA = 1000000; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector A(N); for (int &x : A) cin >> x; vector best(MAXA + 1, 0); int ans = 0; for (int x : A) { int cur = 1; for (int d = 1; d * d <= x; d++) { if (x % d == 0) { cur = max(cur, best[d] + 1); if (d * d != x) cur = max(cur, best[x / d] + 1); } } best[x] = max(best[x], cur); ans = max(ans, cur); } cout << ans; }