#include using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i++) #define all(v) begin(v), end(v) template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int main() { int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; vector dp(n); vector R(100010, -1); rep(i, n) { dp[i] = 1; for (int d = 1; d * d <= a[i]; d++) { if (a[i] % d != 0) continue; if (R[d] != -1) chmax(dp[i], dp[R[d]] + 1); if (R[a[i] / d] != -1) chmax(dp[i], dp[R[a[i] / d]] + 1); } R[a[i]] = i; } cout << *max_element(all(dp)) << "\n"; }