#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N], f[N], Max, Gcd[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    f[i] = 1;
    int x = a[i];
    for (int j = 2; j <= sqrt(x); j++) {
      if (x % j) continue;
      f[i] = max(Gcd[j] + 1, f[i]);
      f[i] = max(Gcd[x / j] + 1, f[i]);
    }
    f[i] = max(f[i], Gcd[x] + 1);
    for (int j = 2; j <= sqrt(x); j++) {
      if (x % j) continue;
      Gcd[j] = max(Gcd[j], f[i]);
      if (x / j != j) Gcd[x / j] = max(Gcd[x / j], f[i]);
    }
    Gcd[x] = max(Gcd[x], f[i]);
    Max = max(Max, f[i]);
  }
  printf("%d", Max);
  return 0;
}
