#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
const long long M = 1e9 + 7;
const long long N = 1e5 + 10;
vector<long long> lpf(N, 0);
map<long long, long long> dp;
map<long long, set<long long>> mp;
void spf() {
  for (long long i = 2; i < N; i++) {
    if (lpf[i] == 0) {
      lpf[i] = i;
      for (long long j = i * i; j < N; j += i) lpf[j] = i;
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  spf();
  long long ans = 1;
  for (long long i = 0; i < n; i++) {
    if (arr[i] == 1) continue;
    long long start = arr[i];
    while (start > 1) {
      mp[arr[i]].insert(lpf[start]);
      start /= lpf[start];
    }
  }
  for (long long i = 0; i < n; i++) {
    if (arr[i] == 1) continue;
    long long mx = -1;
    for (auto x : mp[arr[i]]) {
      mx = max(mx, dp[x]);
    }
    ans = max(ans, mx + 1);
    for (auto x : mp[arr[i]]) {
      dp[x] = mx + 1;
    }
  }
  cout << ans;
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
