#include <bits/stdc++.h>
using namespace std;
int memo[100003], A[100003];
int F[100003], last[100003];
void criba() {
  for (int i = 2; i * i < 100003; i++) {
    if (!F[i])
      for (int j = i * i; j < 100003; j += i) F[j] = i;
  }
  for (int i = 2; i < 100003; i++)
    if (F[i] == 0) F[i] = i;
}
int main() {
  int n;
  criba();
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  memset(memo, 0, sizeof memo);
  memset(last, -1, sizeof last);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    memo[i] = 1;
    while (A[i] > 1) {
      int f = F[A[i]];
      if (last[f] >= 0 && last[f] != i)
        memo[i] = max(memo[i], 1 + memo[last[f]]);
      last[f] = i;
      A[i] /= f;
    }
    ans = max(ans, memo[i]);
  }
  printf("%d\n", ans);
}
