#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N], a[N], n;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  if (n == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] == 1) continue;
    int d = 2, mx = 0, x = a[i];
    while (d * d <= x)
      if (x % d == 0) {
        mx = max(mx, dp[d] + 1);
        x /= d;
      } else
        ++d;
    mx = max(mx, dp[x] + 1);
    d = 2;
    x = a[i];
    while (d * d <= x)
      if (x % d == 0) {
        dp[d] = max(dp[d], mx);
        x /= d;
      } else
        ++d;
    dp[x] = max(dp[x], mx);
  }
  int mx = 0;
  for (int i = 1; i < N; ++i) mx = max(mx, dp[i]);
  cout << mx;
  return 0;
}
