#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long template vector make_vec(size_t a) { return vector(a); } template auto make_vec(size_t a, Ts... ts) { return vector(ts...))>(a, make_vec(ts...)); } template typename enable_if::value == 0>::type fill(T &t, const V &v) { t = v; } template typename enable_if::value != 0>::type fill(T &t, const V &v){ for (auto &e : t) fill(e, v); } // auto v = make_vec(h, w); // fill(v, 0); signed main(){ int n; cin >> n; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector dp(3e5+1, 0); for(int i = 0; i < n; i++){ for(int j = a[i]*2; j <= 3e5; j+=a[i]){ dp[j] = max(dp[j], dp[i] + 1); } } cout << *max_element(dp.begin(),dp.end()) << endl; return 0; }