// yuki 979 Longest Divisor Sequence // 2020.2.26 bal4u #include #include int getchar_unlocked(void); #define gc() getchar_unlocked() int in() { // 整数の入力 int n = 0; int c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } int tbl[300005]; int ans = 1; static inline void hmax(int *a, int b, int c) { if (*a < b) *a = b; if (*a < c) *a = c; } void calc(int a) { int i, b = sqrt(a); int ma = 0; if (tbl[1]) ma = 1; for (i = 2; i <= b; ++i) { if (a % i == 0) hmax(&ma, tbl[i], tbl[a/i]); } if (ma >= tbl[a]) { tbl[a] = ++ma; if (ma > ans) ans = ma; } } int main() { int i, N, A; N = in(); while (N--) { A = in(); if (tbl[A] == 0) tbl[A] = 1; if (A > 1) calc(A); } printf("%d\n", ans); return 0; }