#include <bits/stdc++.h>
using namespace std;
long long n;
long long arr[100005], dp[100005];
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (n == 1) {
    cout << 1;
    return;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    vector<long long> v;
    for (long long j = 2; j <= sqrt(arr[i]); j++) {
      if (arr[i] % j == 0) v.push_back(j);
      while (arr[i] % j == 0) arr[i] /= j;
    }
    if (arr[i] != 1) v.push_back(arr[i]);
    long long temp = 0;
    for (long long j = 0; j < v.size(); j++) {
      dp[v[j]]++;
      temp = max(temp, dp[v[j]]);
    }
    for (long long j = 0; j < v.size(); j++) dp[v[j]] = temp;
    ans = max(ans, temp);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) solve();
  return 0;
}
