#include <bits/stdc++.h>
using namespace std;
int j, s[100005], p[100005], i, n, a, m, as = 1;
int main() {
  scanf("%d", &n);
  for (i = 2; i < 100005; i++)
    if (!s[i])
      for (j = i; j < 100005; j += i) s[j] = i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    m = 0;
    for (j = a; j != 1; j /= s[j]) m = max(m, p[s[j]] + 1);
    for (j = a; j != 1; j /= s[j]) p[s[j]] = max(p[s[j]], m);
    as = max(as, m);
  }
  printf("%d", as);
  return 0;
}
