#include using namespace std; #define rep(i,a,b) for(int i=a;i enumdiv(ll n) { vector S; for (ll i = 1; i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); } sort(S.begin(), S.end()); return S; } //----------------------------------------------------------------- int dp[1010101]; int main() { scanf("%d", &N); rep(i, 0, N) scanf("%d", &x[i]); sort(x, x + N); rep(i, 0, N) dp[x[i]] = 1; rep(i, 1, 1000001) if(dp[i]){ auto v = enumdiv(i); for (int j : v) if(j != i) dp[i] = max(dp[i], dp[j] + 1); } int ans = 0; rep(i, 0, N) ans = max(ans, dp[x[i]]); cout << ans << endl; }