#include using namespace std; using i64 = int64_t; using vi = vector; using vvi = vector; int main() { int n; cin >> n; vi as(n), rev(101010, -1); for (int i = 0; i < n; i++) { cin >> as[i]; } sort(as.begin(), as.end()); for (int i = 0; i < n; i++) { rev[as[i]] = i; } vi dp(n); dp[0] = 1; for (int i = 1; i < n; i++) { i64 t = 0; for (int j = 1; j * j <= as[i]; j++) { if (as[i] % j == 0) { if (rev[j] != -1) { t = max(t, dp[rev[j]] + 1); } if (rev[as[i] / j] != -1) { t = max(t, dp[rev[as[i] / j]] + 1); } } } dp[i] = t; } i64 ans = 1; for (int i = 1; i < n; i++) { // cout << dp[i] << endl; ans = max(ans, dp[i]); } cout << ans << endl; }