#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5;
vector<int> pr[M];
int dp[M], a[M];
bool mark[M];
void pre() {
  for (int i = 2; i < M; i++)
    if (!mark[i])
      for (int j = 2 * i; j < M; j += i) pr[j].push_back(i), mark[j] = 1;
}
int32_t main() {
  pre();
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  if (n == 1 && a[0] == 1) return cout << 1 << endl, 0;
  for (int i = 0; i < n; i++) {
    for (auto p : pr[a[i]]) ((dp[a[i]]) = max((dp[a[i]]), (dp[p])));
    dp[a[i]]++;
    for (auto p : pr[a[i]]) ((dp[p]) = max((dp[p]), (dp[a[i]])));
    ((ans) = max((ans), (dp[a[i]])));
  }
  return cout << ans << endl, 0;
}
