#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX;
const long long SZ = 1e5 + 5;
const long long mod = 1e9 + 7;
bool st[SZ];
vector<long long> prime;
void sieve() {
  long long i, j;
  st[0] = st[1] = 1;
  for (i = 2; i * i < SZ; i++) {
    if (!st[i]) {
      for (j = i * i; j < SZ; j += i) st[j] = 1;
    }
  }
  prime.push_back(2);
  for (i = 3; i < SZ; i += 2) {
    if (!st[i]) prime.push_back(i);
  }
}
vector<long long> fr;
void factorize(long long n) {
  fr.clear();
  long long sqrtn = sqrt(n);
  for (long long i = 0; i < prime.size() && prime[i] <= sqrtn; i++) {
    if (n % prime[i] == 0) {
      fr.push_back(prime[i]);
      while (n % prime[i] == 0) {
        n /= prime[i];
      }
    }
  }
  if (n > 1) fr.push_back(n);
}
long long f[SZ], a[SZ];
int main() {
  sieve();
  long long t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
  string s, s1, s2;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = n; i >= 1; i--) {
    factorize(a[i]);
    c = 0;
    for (j = 0; j < fr.size(); j++) {
      c = max(c, f[fr[j]]);
    }
    c++;
    for (j = 0; j < fr.size(); j++) {
      f[fr[j]] = c;
    }
    ans = max(ans, c);
  }
  printf("%lld\n", ans);
  return 0;
}
