#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9;
inline int rd() {
  int x = 0;
  char c = getchar();
  bool f = false;
  while (!isdigit(c)) {
    if (c == '-') f = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f ? -x : x;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int sqr(int x) { return x * x; }
int n;
int a[1000005];
int dp[1000005];
int ans;
void sol(int x) {
  int maxx = -0x7fffffff;
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      maxx = max(max(maxx, dp[i]), dp[x / i]);
    }
  }
  maxx = max(maxx, dp[x]);
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      dp[i] = maxx + 1;
      dp[x / i] = maxx + 1;
      while (x % i == 0) x /= i;
    }
  }
  dp[x] = maxx + 1;
  ans = max(ans, maxx + 1);
}
int main() {
  n = rd();
  for (int i = 1; i <= n; i++) {
    a[i] = rd();
  }
  for (int i = 1; i <= n; i++) sol(a[i]);
  printf("%d\n", ans);
  return 0;
}
