#include <bits/stdc++.h>
using namespace std;
const int X = 100009;
int arr[X], Ans[X], n;
vector<int> V[X];
int T() {
  int MaX = 0;
  for (int i = 0; i < n; i++) {
    for (int l = 2; l * l <= arr[i]; l++)
      if (arr[i] % l == 0) {
        V[i].push_back(l);
        while (arr[i] % l == 0) arr[i] /= l;
      }
    if (arr[i] > 1) V[i].push_back(arr[i]);
  }
  for (int i = 0; i < n; i++) {
    int Res = 0;
    for (int q = 0; q < (int)V[i].size(); q++) Res = max(Ans[V[i][q]] + 1, Res);
    for (int q = 0; q < (int)V[i].size(); q++) Ans[V[i][q]] = Res;
    MaX = max(MaX, Res);
  }
  if (n == 1) return 1;
  return MaX;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(Ans, 0, sizeof Ans);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cout << T() << endl;
}
