#include <bits/stdc++.h>
using namespace std;
inline int Readint() {
  int ret = 0;
  int f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f *= -1;
  } while (ch >= 0 && (ch < '0' || ch > '9'));
  while ('0' <= ch && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * f;
}
void open() {
  freopen("run.in", "r", stdin);
  freopen("run.out", "w", stdout);
}
void close() {
  fclose(stdin);
  fclose(stdout);
}
const int MAXN = 1E5;
int tot;
int pr[MAXN];
int chk[MAXN];
int n;
int dp[MAXN];
void prepare() {
  chk[1] = 1;
  for (int i = 2, _END_ = MAXN; i <= _END_; i++) {
    if (!chk[i]) {
      tot++;
      pr[tot] = i;
    }
    for (int j = 1; j <= tot && pr[j] * i <= MAXN; j++) {
      chk[pr[j] * i] = 1;
      if (i % pr[j] == 0) break;
    }
  }
}
void init() {
  n = Readint();
  int ans = 0, tmp = 0;
  int x, a;
  for (int i = 1, _END_ = n; i <= _END_; i++) {
    tmp = 0;
    x = a = Readint();
    for (int j = 1, _END_ = tot; j <= _END_; j++) {
      if (x % pr[j] == 0) {
        tmp = max(tmp, dp[j]);
        while (x % pr[j] == 0) x /= pr[j];
      }
      if (x == 1) break;
    }
    tmp++;
    ans = max(ans, tmp);
    for (int j = 1, _END_ = tot; j <= _END_; j++) {
      if (a % pr[j] == 0) {
        dp[j] = max(dp[j], tmp);
        while (a % pr[j] == 0) a /= pr[j];
      }
      if (a == 1) break;
    }
  }
  printf("%d\n", ans);
}
int main() {
  int _ = 0;
  prepare();
  init();
  close();
  return 0;
}
