#include <bits/stdc++.h>
using namespace std;
bool sieve[100000];
int primes[100000];
int dp[100000] = {0};
int divis[100000] = {0};
int a[100000];
int main() {
  long long j, x, n;
  cin >> n;
  int m = 0;
  for (long long i = 2; i < 100000; ++i) {
    if (!sieve[i]) {
      for (long long j = i * i; j < 100000; j += i) sieve[j] = true;
      primes[m++] = i;
    }
  }
  for (j = 0; j < n; ++j) cin >> a[j];
  for (int i = 0; i < n; ++i) {
    x = a[i];
    for (int k = 0; primes[k] * primes[k] <= x; ++k) {
      if (x % primes[k] == 0) {
        j = primes[k];
        dp[i] = max(dp[i], divis[j] + 1);
        while (x % j == 0) x /= j;
      }
    }
    if (x > 1) {
      dp[i] = max(dp[i], divis[x] + 1);
    }
    x = a[i];
    for (int k = 0; primes[k] * primes[k] <= x; ++k) {
      if (x % primes[k] == 0) {
        j = primes[k];
        while (x % j == 0) x /= j;
        divis[j] = dp[i];
      }
    }
    if (x > 1) {
      divis[x] = dp[i];
    }
  }
  int ans = *max_element(dp, dp + n);
  if (ans == 0) ++ans;
  cout << ans << endl;
  return 0;
}
