#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const long long linf = (1ll << 62) - 1;
const int dirx[] = {-1, 0, 0, 1, -1, -1, 1, 1},
          diry[] = {0, -1, 1, 0, -1, 1, -1, 1};
const double ERR = 1e-11, PI = (2 * acos(0.0));
template <class T>
bool cmpmin(T a, T b) {
  return a < b;
}
template <class T>
bool cmpmax(T a, T b) {
  return a > b;
}
template <class T>
inline T ABS(T a) {
  return ((a < 0) ? (-a) : (a));
}
template <class T>
T GCD(T a, T b) {
  return ((!b) ? (a) : GCD(b, a % b));
}
template <class T>
T fastPow(T Base, T Power) {
  T Result = 1;
  while (Power > 0) {
    if (Power & ((T)1)) Result *= Base;
    Power >>= 1;
    Base *= Base;
  }
  return Result;
}
template <class T>
T fastModPow(T Base, T Power, T Mod) {
  T Result = 1;
  while (Power > 0) {
    if (Power & ((T)1)) Result = (Result * Base) % Mod;
    Power >>= 1;
    Base = (Base * Base) % Mod;
  }
  return (Result % Mod);
}
inline int compDouble(double x, double y) {
  double d = x - y;
  if (d - ERR > 0.0)
    return 1;
  else if (d + ERR < 0.0)
    return -1;
  else
    return 0;
}
inline void file() { freopen("rail.txt", "r", stdin); }
long long Eular(long long n) {
  int i;
  long long ret = n;
  for (i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      ret -= ret / i;
      while (n % i == 0) n /= i;
      if (n == 1) break;
    }
  }
  if (n != 1) ret -= ret / n;
  return ret;
}
int dp[1000005];
int main() {
  int n, a, i, ans = 0, j, m;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    m = 0;
    for (j = 2; j * j <= a; j++) {
      if (a % j == 0) {
        m = ((m) < (((dp[j]) < (dp[a / j]) ? (dp[a / j]) : (dp[j])))
                 ? (((dp[j]) < (dp[a / j]) ? (dp[a / j]) : (dp[j])))
                 : (m));
      }
    }
    for (j = 2; j * j <= a; j++) {
      if (a % j == 0) {
        dp[j] = dp[a / j] = ((m + 1) < (dp[j]) ? (dp[j]) : (m + 1));
      }
    }
    dp[a] = m + 1;
    ans = ((ans) < (dp[a]) ? (dp[a]) : (ans));
  }
  printf("%d\n", ans);
  return 0;
}
