#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX;
const int mod = 1e9 + 7;
vector<int> primes;
vector<int> sieve(const int n) {
  vector<int> prime(n + 1, 0);
  prime[1] = 1;
  for (int p = 2; p * p <= n; p++) {
    if (!prime[p]) {
      for (int i = p * p; i <= n; i += p) prime[i] = p;
    }
  }
  for (int i = 2; i <= n; i++)
    if (!prime[i]) prime[i] = i;
  return prime;
}
vector<int> getDivs(int x) {
  vector<int> divs;
  while (x > 1) {
    int div = primes[x];
    int cnt = 0;
    while (x % div == 0) {
      x /= div;
      cnt++;
    }
    if (cnt) divs.push_back(div);
  }
  if (x > 1) divs.push_back(x);
  return divs;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : (a)) cin >> x;
  vector<int> pr(100010, 0);
  int ans = 1;
  for (int i = n - 1; i >= 0; i--) {
    vector<int> divs = getDivs(a[i]);
    int mx = 0;
    for (auto &x : (divs)) {
      pr[x] = pr[x] + 1;
      mx = max(mx, pr[x]);
    }
    for (auto &x : (divs)) pr[x] = mx;
    ans = max(ans, mx);
  }
  cout << ans << endl;
}
int main() {
  primes = sieve(100010);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
