#include <bits/stdc++.h>
using namespace std;
int i, j, k, x, y, z, n, m;
int a[150001];
int best[150001];
int g[150001];
int ANS;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = n; i > 0; i--) {
    int ans = 0;
    g[0] = 0;
    for (j = 2, x = a[i]; j * j <= x; j++)
      if (x % j == 0) {
        g[++g[0]] = j;
        while (x % j == 0) x /= j;
        ans = max(ans, best[j]);
      }
    if (x != 1) {
      ans = max(ans, best[x]);
      g[++g[0]] = x;
    }
    ans++;
    if (ans > ANS) ANS = ans;
    for (j = 1; j <= g[0]; j++) best[g[j]] = ans;
  }
  printf("%d\n", ANS);
  return 0;
}
