#include <bits/stdc++.h>
int p[100004];
int a[100004];
int main() {
  int n;
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  int j;
  for (i = 0; i < n; i++) {
    int m = 0;
    for (j = 2; j * j <= a[i]; j++) {
      if (a[i] % j == 0) {
        if (p[j] > m) m = p[j];
        if (p[a[i] / j] > m) m = p[a[i] / j];
      }
    }
    m = m + 1;
    for (j = 1; j * j <= a[i]; j++) {
      if (a[i] % j == 0) {
        p[j] = m;
        p[a[i] / j] = m;
      }
    }
  }
  int max = 1;
  for (i = 2; i <= 100000; i++) {
    if (p[i] > max) max = p[i];
  }
  printf("%d", max);
  return 0;
}
