#include <bits/stdc++.h>
using namespace std;
int fac[100000];
int dp[100001];
int mulbest[100001];
int main() {
  for (int i = 0; i <= 100000; i++) fac[i] = i;
  for (int i = 2; i <= 320; i++) {
    if (fac[i] != i) continue;
    fac[i] = i;
    for (int j = 2 * i; j <= 100000; j += i) fac[j] = i;
  }
  int N;
  scanf("%d", &N);
  int bestest = 0;
  for (int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    int best = 1;
    int cur = a;
    while (cur != 1) {
      best = max(best, mulbest[fac[cur]] + 1);
      cur /= fac[cur];
    }
    cur = a;
    while (cur != 1) {
      mulbest[fac[cur]] = max(mulbest[fac[cur]], best);
      cur /= fac[cur];
    }
    dp[i] = best;
    bestest = max(bestest, best);
  }
  printf("%d\n", bestest);
  return 0;
}
