#include <bits/stdc++.h>
int p[100007], a[100007];
int main() {
  int n, i, ans, j;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      p[i + 1] = 0;
    }
    for (i = 0, ans = 0; i < n; i++) {
      int res = 0, tmp = a[i];
      for (j = 2; j * j <= tmp; j++)
        if (tmp % j == 0) {
          if (p[j] > res) res = p[j];
          while (tmp % j == 0) tmp /= j;
        }
      if (tmp > 1 && p[tmp] > res) res = p[tmp];
      res += 1;
      if (res > ans) ans = res;
      for (j = 2; j * j <= a[i]; j++)
        if (a[i] % j == 0) {
          p[j] = res;
          while (a[i] % j == 0) a[i] /= j;
        }
      if (a[i] > 1) p[a[i]] = res;
    }
    printf("%d\n", ans);
  }
}
