#include #include #include #include #define ALL(V) std::begin(V), std::end(V) const int SIZE = 1e5 + 10; template void chmax(T &a, const T &b) { a = std::max(a, b); } int main() { std::vector> divs(SIZE); for (int i = 1; i < SIZE; i++) { for (int j = 1; i * j < SIZE; j++) { divs[i * j].push_back(i); } } int N; std::cin >> N; std::vector A(N); for (auto &e : A) std::cin >> e; std::vector dp(SIZE); for (auto e : A) { int v = 0; for (auto d : divs[e]) chmax(v, dp[d] + 1); chmax(dp[e], v); } std::cout << *std::max_element(ALL(dp)) << std::endl; return 0; }