#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
int sieve[100005];
vector<int> primes[100005];
int cntp[100005];
int ans[100005];
int a[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], ans[i] = 1;
  for (int i = 2; i <= 100005; i++) {
    if (!sieve[i]) {
      primes[i].push_back(i);
      for (int j = 2 * i; j <= 100005; j += i) {
        sieve[j] = 1;
        primes[j].push_back(i);
      }
    }
  }
  int fans = 1;
  memset(cntp, 0, sizeof cntp);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < primes[a[i]].size(); j++) {
      ans[i] = max(ans[i], cntp[primes[a[i]][j]] + 1);
    }
    for (int j = 0; j < primes[a[i]].size(); j++) {
      cntp[primes[a[i]][j]] = max(cntp[primes[a[i]][j]], ans[i]);
    }
    fans = max(fans, ans[i]);
  }
  cout << fans;
  return 0;
}
