#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> dp(100005, 0);
  long long x;
  long long ans = 1;
  while (n--) {
    cin >> x;
    vector<long long> d;
    for (long long i = 1; i * i <= x; i++) {
      if (x % i == 0 and i != 1) d.push_back(i);
      if (x % i == 0 and x / i != i) d.push_back(x / i);
    }
    vector<long long> gg(d.size(), 0);
    for (long long j = 0; j < d.size(); j++) {
      long long mx = 0;
      for (long long k = 0; k < d.size(); k++)
        if (j != k) mx = max(dp[d[k]], mx);
      gg[j] = max(mx, dp[d[j]]);
    }
    for (long long j = 0; j < d.size(); j++) dp[d[j]] = gg[j] + 1;
  }
  for (long long i = 2; i < 100005; i++) ans = max(ans, dp[i]);
  cout << ans;
  return 0;
}
