#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, x, a[maxn], b[maxn], p, t, r, mx, res;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    t = x;
    r = 0;
    p = 0;
    for (int j = 2; 1ll * j * j <= x; ++j) {
      if (t % j == 0) {
        while (t % j == 0) {
          t /= j;
        }
        b[r++] = j;
        p = p > a[j] ? p : a[j];
      }
    }
    if (t > 1) {
      b[r++] = t;
      p = p > a[t] ? p : a[t];
    }
    for (int j = 0; j < r; ++j) {
      a[b[j]] = p + 1;
    }
    mx = p + 1;
    res = res > mx ? res : mx;
  }
  printf("%d", res);
  return 0;
}
