#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, (a % b));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  vector<int> dp(100001, 0);
  for (long long int i = 0; i < n; i++) {
    vector<int> div;
    int mx = 0;
    for (long long int j = 2; j < sqrt(v[i]) + 1; j++) {
      if (v[i] % j == 0) {
        if (v[i] != j) {
          div.push_back(v[i] / j);
          div.push_back(j);
          mx = max(dp[j], mx);
          mx = max(dp[v[i] / j], mx);
        } else {
          div.push_back(j);
          mx = max(dp[j], mx);
        }
      }
    }
    if (int(div.size()) <= 1) dp[v[i]] = mx + 1;
    for (long long int j = 0; j < int(div.size()); j++) {
      dp[div[j]] = mx + 1;
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
  return 0;
}
