#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)(1e5) + 10;
int n;
int nums[MAXN], last[MAXN], dp[MAXN], ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  memset(last, -1, sizeof(last));
  for (int i = 0; i < n; ++i) cin >> nums[i];
  ans = 1;
  for (int i = n - 1; i >= 0; --i) {
    int cur = nums[i];
    dp[i] = 1;
    for (int k = 2; k * k <= cur; ++k) {
      if (cur % k == 0) {
        if (last[k] != -1) dp[i] = max(dp[i], dp[last[k]] + 1);
        while (cur % k == 0) cur /= k;
        last[k] = i;
      }
    }
    if (cur != 1) {
      if (last[cur] != -1) dp[i] = max(dp[i], dp[last[cur]] + 1);
      last[cur] = i;
    }
    ans = max(ans, dp[i]);
  }
  cout << ans << '\n';
  return 0;
}
