#include <bits/stdc++.h>
void fileio_in_out() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
void fileio_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int m, n, k, nump = 0, ans = 0;
int a[1111111], b[1111111], f[1111111];
int main() {
  int i, j, l;
  memset(b, 0, sizeof(b));
  memset(f, 0, sizeof(f));
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    for (j = 1; j * j <= a[i]; j++)
      if (a[i] % j == 0) {
        f[i] =
            (((f[i]) > (f[b[a[i] / j]] + 1)) ? (f[i]) : (f[b[a[i] / j]] + 1));
        if (j > 1) f[i] = (((f[i]) > (f[b[j]] + 1)) ? (f[i]) : (f[b[j]] + 1));
        ans = (((ans) > (f[i])) ? (ans) : (f[i]));
        b[j] = b[a[i] / j] = i;
      }
  }
  printf("%d\n", ans);
  return 0;
}
