#include <bits/stdc++.h>
using namespace std;
int prime[150000];
int num[150000];
int ans[150000];
bool mark[150000];
vector<int> vec[150000];
void cprime() {
  for (int a = 2; a <= 100000; a++) {
    if (mark[a] == false) {
      for (int b = a; b <= 100000; b += a) {
        vec[b].push_back(a);
        mark[b] = true;
      }
    }
  }
}
int main() {
  cprime();
  int n;
  scanf("%d", &n);
  int maxx = 1;
  for (int a = 1; a <= n; a++) {
    int t;
    scanf("%d", &t);
    for (int b = 0; b < vec[t].size(); b++) {
      ans[a] = max(ans[a], ans[prime[vec[t][b]]] + 1);
      prime[vec[t][b]] = a;
    }
    maxx = max(ans[a], maxx);
  }
  printf("%d\n", maxx);
}
