#include <bits/stdc++.h>
using namespace std;
void div(vector<int> &divisors, int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      divisors.push_back(i);
      if (x / i != i) divisors.push_back(x / i);
    }
  }
  divisors.push_back(x);
}
int main() {
  int n;
  cin >> n;
  int dp[100005] = {}, d[100005] = {};
  for (int i = 0; i < n; i++) {
    vector<int> divisors;
    int x;
    cin >> x;
    if (x == 1) continue;
    div(divisors, x);
    for (int j = 0; j < divisors.size(); j++)
      dp[x] = max(dp[x], d[divisors[j]] + 1);
    for (int j = 0; j < divisors.size(); j++) d[divisors[j]] = dp[x];
  }
  int ans = 1;
  for (int i = 1; i <= 100004; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
}
