/*** author: yuji9511 ***/ #include using namespace std; using ll = long long; using lpair = pair; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);i>=(n);i--) #define printa(x,n) for(ll i=0;i void print(H&& h, T&&... t){cout<(t)...);} struct Integer{ public: ll gcd(ll a,ll b){return b ? gcd(b, a % b) : a;} ll lcm(ll a,ll b){return a / gcd(a, b) * b;} bool isPrime(ll x){ if(x < 2) return false; if(x == 2) return true; if(x % 2 == 0) return false; for(ll i = 3;i <= sqrt(x) + 1;i += 2) if(x % i == 0) return false; return true; } vector divisor(ll M){ vector dd; for(ll i = 1; i * i <= M; i++){ if(M % i == 0){ dd.push_back(i); if(i * i != M) dd.push_back(M / i); } } sort(dd.begin(), dd.end()); return dd; } vector factor(ll M){ //素因数分解 vector dd; if(M == 1){ dd.push_back(1); return dd; } for(ll i = 2; i*i <= M; i++){ while(M % i == 0){ dd.push_back(i); M /= i; } } if(M != 1) dd.push_back(M); sort(dd.begin(), dd.end()); return dd; } }; ll A[300010]; ll cnt[300010] = {}; vector pos[300010]; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; rep(i,0,N) cin >> A[i]; Integer it; rep(i,0,N){ if(cnt[A[i]] > 0){ A[i] = INF; }else{ cnt[A[i]]++; } } rep(i,0,N){ if(A[i] != INF) pos[A[i]].push_back(i); } ll ans = 0; ll dp[300010] = {}; rep(i,0,N){ if(A[i] == INF) continue; dp[i] = 1; vector dd = it.divisor(A[i]); for(auto &e: dd){ for(auto &f: pos[e]){ if(f >= i) break; dp[i] = max(dp[i], dp[f]+1); } } } rep(i,0,N) ans = max(ans, dp[i]); print(ans); }