#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
int a[N], n, f[N], p[N], p_c;
bool v[N];
inline void pre() {
  int N = 101000;
  memset(v, 1, sizeof v);
  v[1] = false;
  int m = (int)sqrt(N + 0.5);
  for (int i = 2; i <= m; i++)
    if (v[i])
      for (int j = i * i; j <= N; j += i) v[j] = false;
  for (int i = 1; i <= N; i++)
    if (v[i]) p[++p_c] = i;
}
int main() {
  pre();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int z(0), t = a[i];
    for (int j = 1; j <= p_c && t != 1; j++)
      if (t % p[j] == 0) {
        z = max(z, f[j]);
        while (t % p[j] == 0) t /= p[j];
      }
    t = a[i];
    for (int j = 1; j <= p_c && t != 1; j++)
      if (t % p[j] == 0) {
        f[j] = max(f[j], z + 1);
        while (t % p[j] == 0) t /= p[j];
      }
  }
  int z(1);
  for (int i = 1; i <= p_c; i++) z = max(z, f[i]);
  printf("%d", z);
  return 0;
}
