#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[100001], divisor[100001], dp[100001], ans = 0;
  memset(dp, 0, sizeof(dp));
  memset(divisor, 0, sizeof(divisor));
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    dp[i] = 1;
    int nrep = sqrt(arr[i]);
    for (int j = 2; j <= nrep; ++j) {
      if (arr[i] % j != 0) continue;
      dp[i] = max(dp[i], divisor[j] + 1);
      dp[i] = max(dp[i], divisor[arr[i] / j] + 1);
    }
    for (int j = 2; j <= nrep; ++j) {
      if (arr[i] % j != 0) continue;
      divisor[j] = dp[i];
      divisor[arr[i] / j] = dp[i];
    }
    divisor[arr[i]] = dp[i];
    ans = max(ans, dp[i]);
  }
  cout << ans;
}
