#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int a[n]; for (auto &i : a) i = ri(); static int max[300001]; for (int i = 0; i < n; i++) { std::vector divs; for (int j = 1; j * j <= a[i]; j++) { if (a[i] % j == 0) { divs.push_back(j); if (j > 1) divs.push_back(a[i] / j); } } int cur = 0; for (auto j : divs) cur = std::max(cur, max[j]); max[a[i]] = std::max(max[a[i]], cur + 1); } printf("%d\n", *std::max_element(max, max + 300001)); return 0; }