#include using i64 = long long; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; std::cin >> n; std::vector a(n); for (int i = 0; i < n; i++) { std::cin >> a[i]; } int m = *std::max_element(a.begin(), a.end()); std::vector> div(m + 1); for (int i = 1; i <= m; i++) { for (int j = i; j <= m; j += i) { div[j].push_back(i); } } std::vector f(m + 1); int ans = 0; for (int i = 0; i < n; i++) { int v = 0; for (auto x : div[a[i]]) { v = std::max(v, f[x] + 1); } f[a[i]] = v; ans = std::max(ans, v); } std::cout << ans << "\n"; return 0; }