#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n, ans[N], b[N];
int main() {
  scanf("%d", &n);
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    b[0] = 0;
    int to = (int)sqrt((double)a[i]), k = 0;
    for (int j = 1; j <= to; j++)
      if (a[i] % j == 0) {
        if (j > 1) b[++b[0]] = j, k = max(k, ans[j]);
        if (j * j != a[i]) b[++b[0]] = a[i] / j, k = max(k, ans[a[i] / j]);
      }
    for (int j = 1; j <= b[0]; j++) ans[b[j]] = max(ans[b[j]], k + 1);
  }
  for (int i = 1; i <= (int)1e5; i++) ans[0] = max(ans[0], ans[i]);
  printf("%d\n", ans[0]);
  return 0;
}
