#include <bits/stdc++.h>
using namespace std;
int M, a[2000000], n, ans;
int d[2000000];
int DP(int v, int x) {
  M = 0;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) M = max(M, d[i]);
    while (x % i == 0) x /= i;
  }
  if (x != 1) M = max(M, d[x]);
  x = v;
  M++;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) d[i] = M;
    while (x % i == 0) x /= i;
  }
  if (x != 1) d[x] = M;
  return M;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) ans = max(ans, DP(a[i], a[i]));
  printf("%d", ans);
  return 0;
}
