#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int res = 0;
  char c;
  int f = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * f;
}
const int N = 100010, MOD = 1e9 + 7;
int a[N];
int dp[N];
bitset<N> vis;
int prime[N];
int p = 0;
void init() {
  for (int i = 2; i < N; i++) {
    if (!vis[i]) {
      prime[p++] = i;
      for (int j = i + i; j < N; j += i) vis[j] = 1;
    }
  }
}
int main() {
  init();
  int n = in();
  if (n == 1) return 0 * puts("1");
  for (int i = 0; i < n; i++) {
    a[i] = in();
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int t = a[i], mx = 0;
    for (int j = 0; j < p && prime[j] * prime[j] <= t; j++) {
      if (t % prime[j] == 0) {
        mx = max(mx, dp[prime[j]] + 1);
        while (t % prime[j] == 0) t /= prime[j];
      }
    }
    if (t > 1) mx = max(mx, dp[t] + 1);
    ;
    t = a[i];
    for (int j = 0; j < p && prime[j] * prime[j] <= t; j++) {
      if (t % prime[j] == 0) {
        dp[prime[j]] = mx;
        while (t % prime[j] == 0) t /= prime[j];
      }
    }
    if (t > 1) dp[t] = mx;
    ans = max(ans, mx);
  }
  cout << ans << endl;
  return 0;
}
