#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> dp(100005);
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long mx = 1;
    for (long long i = 0; i < n; i++) {
      set<long long> s;
      for (long long j = 2; j * j <= a[i]; j++) {
        while (a[i] % j == 0) {
          s.insert(j);
          a[i] = a[i] / j;
        }
      }
      if (a[i] > 1) s.insert(a[i]);
      long long ans = 1;
      for (auto j : s) {
        ans = max(ans, dp[j] + 1);
      }
      mx = max(mx, ans);
      for (auto j : s) {
        dp[j] = ans;
      }
    }
    cout << mx << endl;
  }
  return 0;
}
