#include <bits/stdc++.h>
int cnt, d[111111], v[111111], t[111111];
int main() {
  int n, i, j, max, a, count, b, ans;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%d", &v[i]);
    }
    a = v[n - 1];
    for (i = 0; i <= a; i++) d[i] = 0;
    ans = 0;
    for (i = 0; i < n; i++) {
      a = v[i];
      max = 1;
      for (j = 2; j * j <= a; j++) {
        if (a % j == 0) {
          if (max < d[j] + 1) max = d[j] + 1;
          while (a % j == 0) a /= j;
        }
      }
      if (a > 1 && max < d[a] + 1) max = d[a] + 1;
      if (ans < max) ans = max;
      a = v[i];
      for (j = 2; j * j <= a; j++) {
        if (a % j == 0) {
          if (d[j] < max) d[j] = max;
          while (a % j == 0) a /= j;
        }
      }
      if (a > 1 && max > d[a]) d[a] = max;
    }
    printf("%d\n", ans);
  }
  return 0;
}
