#include #include #include #include constexpr int X = 1000000; void solve() { int n; std::cin >> n; std::vector xs(n); for (auto& x : xs) std::cin >> x; std::sort(xs.rbegin(), xs.rend()); std::vector pos(X + 1, -1); for (int i = 0; i < n; ++i) pos[xs[i]] = i; std::vector dp(n, 1); for (int i = 0; i < n; ++i) { auto x = xs[i]; for (int y = x * 2; y <= xs.front(); y += x) { if (pos[y] == -1) continue; dp[i] = std::max(dp[i], dp[pos[y]] + 1); } } std::cout << *std::max_element(dp.begin(), dp.end()) << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }