#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10;
long long spf[MAXN + 3];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i <= MAXN; i++) spf[i] = i;
  for (long long i = 4; i <= MAXN; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j <= MAXN; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
vector<long long> getFactorization(long long x) {
  vector<long long> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long ar[n + 1];
  for (long long i = 1; i <= n; ++i) cin >> ar[i];
  sieve();
  long long len[MAXN] = {0};
  long long ans = 1;
  for (long long i = 1; i <= n; ++i) {
    vector<long long> temp = getFactorization(ar[i]);
    set<long long> unique(temp.begin(), temp.end());
    long long val = 0;
    for (auto it : unique) val = max(len[it], val);
    for (auto it : unique) len[it] = max(len[it], val + 1);
  }
  for (long long i = 1; i <= MAXN - 10; ++i) ans = max(ans, len[i]);
  cout << ans << "\n";
}
