#include <bits/stdc++.h>
using namespace std;
long long a[100009], dp[100009];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i = 2, j;
  while (i <= 100009) {
    if (a[i] == 0) {
      j = i;
      while (j <= 100009) {
        a[j] = i;
        j += i;
      }
    }
    i++;
  }
  long long n, d, mx, ans = 0;
  cin >> n;
  while (n--) {
    cin >> d;
    vector<long long> v;
    while (d > 1) {
      v.push_back(a[d]);
      mx = a[d];
      while (d % mx == 0) d /= mx;
    }
    mx = 0;
    for (auto x : v) mx = max(mx, dp[x]);
    mx++;
    ans = max(ans, mx);
    for (auto x : v) dp[x] = max(dp[x], mx);
  }
  cout << ans << "\n";
}
