#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const int mod = 1;
const int inf = 1e9;
ll n, t, a[N], x, dp[N];
vector<ll> fac[N];
void sieve() {
  for (int i = 2; i < N; ++i) {
    for (int j = i; j < N; j += i) {
      fac[j].push_back(i);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll res = 1, ans = 0;
  sieve();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    res = 1;
    for (auto j : fac[x]) {
      res = max(res, dp[j] + 1);
    }
    ans = max(res, ans);
    for (auto j : fac[x]) {
      dp[j] = max(dp[j], res);
    }
  }
  cout << ans << "\n";
  return 0;
}
