#include <bits/stdc++.h>
using namespace std;
int INP, AM, REACHEOF;
char BUF[(1 << 12) + 1], *inp = BUF;
const long double PI = acos((long double)-1.0);
const int MN = 100111;
int sieve[MN], f[MN], a[MN], n;
void init() {
  for (int i = (2), _b = (1000); i <= _b; i++)
    if (!sieve[i]) {
      int j = i * i;
      while (j <= 100000) {
        sieve[j] = i;
        j += i;
      }
    }
}
int main() {
  while (scanf("%d", &n) == 1) {
    memset(f, 0, sizeof f);
    for (int i = (1), _b = (n); i <= _b; i++) scanf("%d", &a[i]);
    int res = 0;
    for (int i = (1), _b = (n); i <= _b; i++) {
      f[a[i]] = 1;
      for (int x = 2; x * x <= a[i]; ++x)
        if (a[i] % x == 0) {
          f[a[i]] = max(f[a[i]], f[x] + 1);
          f[a[i]] = max(f[a[i]], f[a[i] / x] + 1);
        }
      for (int x = 2; x * x <= a[i]; ++x)
        if (a[i] % x == 0) {
          f[x] = max(f[x], f[a[i]]);
          f[a[i] / x] = max(f[a[i] / x], f[a[i]]);
        }
      res = max(res, f[a[i]]);
    }
    printf("%d\n", res);
  }
  return 0;
}
