#include <bits/stdc++.h>
using namespace std;
int n, A[100001], dp[100001], divi[100001];
void crib(void) {
  for (int i = 2; i * i <= 100001; i++) {
    if (divi[i]) continue;
    for (int j = i * 2; j < 100001; j += i) {
      divi[j] = i;
    }
  }
}
int main(void) {
  cin >> n;
  memset(dp, 0, sizeof(dp));
  memset(divi, 0, sizeof(divi));
  int rst = 0;
  crib();
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) {
    int it = A[i];
    int m = 0;
    while (divi[it]) {
      if (dp[divi[it]] > m) m = dp[divi[it]];
      it /= divi[it];
    }
    if (dp[it] > m) m = dp[it];
    if (m + 1 > rst) rst = m + 1;
    it = A[i];
    while (divi[it]) {
      dp[divi[it]] = m + 1;
      it /= divi[it];
    }
    dp[it] = m + 1;
  }
  cout << rst << endl;
  return 0;
}
