#include #define EM 1000000 using namespace std; using LL = long long; using P = pair; LL LINF = 1e18; int INF = 1e9; LL mod = 1e9+7; using vint = vector; using vLL = vector; using vvint = vector>; using vvLL = vector>; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(){ int N; cin >> N; vector x(N), cnt(1e6+1, 1); set xx; for(int i = 0;i < N;i++){ cin >> x[i]; xx.insert(x[i]); } sort(x.begin(), x.end()); for(int i = 0;i < N;i++){ for(int j = 2;j*x[i] <= 1e6;j++){ auto itr = xx.find(j*x[i]); if(itr != xx.end()){ cnt[*itr] = max(cnt[*itr], cnt[x[i]]+1); } } } int ans = 0; for(auto c : cnt) ans = max(ans, c); cout << ans << endl; }