#include <bits/stdc++.h>
using namespace std;
int etd[100005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int num;
    int ma = -1;
    scanf("%d", &num);
    vector<int> factors;
    for (int j = 2; j * j <= num; j++) {
      if (num % j == 0) {
        ma = max(ma, etd[j] + 1);
        factors.push_back(j);
      }
      while (num % j == 0) num /= j;
    }
    if (num > 1) {
      ma = max(ma, etd[num] + 1);
      factors.push_back(num);
    }
    for (int j = 0; j < (int)factors.size(); j++) {
      etd[factors[j]] = ma;
    }
  }
  int ans = -1;
  for (int i = 1; i <= 100000; i++) {
    if (ans < etd[i]) ans = etd[i];
  }
  printf("%d\n", max(1, ans));
  return 0;
}
