#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
const int N = 1e5 + 10;
int a[N], n;
int main() {
  scanf("%d", &n);
  if (n == 1) return puts("1") * 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    vector<int> v;
    for (int i = 2; i * i <= x; i++) {
      if (x % i == 0) {
        v.push_back(i);
        while (x % i == 0) x /= i;
      }
    }
    if (x > 1) v.push_back(x);
    int mx = 0;
    for (int i : v) mx = max(mx, a[i]);
    mx++;
    for (auto i : v) a[i] = mx;
  }
  int mx = 0;
  for (int i = 2; i < N; i++) mx = max(mx, a[i]);
  printf("%d\n", mx);
  return 0;
}
