#include <bits/stdc++.h>
using namespace std;
int n, a[100005], dp[100005], divisor[100005], mx;
int main() {
  scanf("%d", &n);
  int ans = 1;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int maxDiv = 0;
    for (int d = 2; d * d <= a[i]; d++)
      if (a[i] % d == 0)
        maxDiv = max(maxDiv, max(divisor[d], divisor[a[i] / d]));
    maxDiv += 1;
    divisor[a[i]] = maxDiv;
    for (int d = 2; d * d <= a[i]; d++)
      if (a[i] % d == 0) divisor[d] = divisor[a[i] / d] = divisor[a[i]];
    ans = max(ans, maxDiv);
  }
  cout << ans << "\n";
  return 0;
}
