#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
int A[100009], dp[100009];
vector<int> L[100009], D[100009];
int best[100009];
int main() {
  int n, i, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
    int a = A[i];
    for (j = 2; j * j <= a; j++) {
      if (a % j == 0) {
        a /= j;
        L[j].push_back(i);
        D[i].push_back(j);
        while (a % j == 0) a /= j;
      }
    }
    if (a != 1) {
      L[a].push_back(i);
      D[i].push_back(a);
    }
  }
  for (i = 0; i < n; i++) {
    dp[i] = 1;
    for (j = 0; j < D[i].size(); j++) {
      int d = D[i][j];
      dp[i] = max(dp[i], best[d] + 1);
    }
    for (j = 0; j < D[i].size(); j++) {
      int d = D[i][j];
      best[d] = dp[i];
    }
  }
  printf("%d\n", *max_element(dp, dp + n));
}
