#include <bits/stdc++.h>
using namespace std;
long long n, a[100005], dp[100005], divi[100005], ans;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    dp[a[i]] = 1;
    for (long long j = 1; j * j <= a[i]; j++) {
      if (a[i] % j) continue;
      if (j != 1) dp[a[i]] = max(dp[a[i]], divi[j] + 1);
      if (j != a[i] / j) dp[a[i]] = max(dp[a[i]], divi[a[i] / j] + 1);
    }
    for (long long j = 1; j * j <= a[i]; j++) {
      if (a[i] % j) continue;
      if (j != 1) divi[j] = max(divi[j], dp[a[i]]);
      if (j != a[i] / j) divi[a[i] / j] = max(divi[a[i] / j], dp[a[i]]);
    }
    ans = max(ans, dp[a[i]]);
  }
  cout << ans;
  return 0;
}
