#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int n, ar[N];
int lpf[N], dp[N];
void build() {
  for (int i = 0; i < N; i++) lpf[i] = i;
  for (int i = 2; i < N; i++)
    if (lpf[i] == i)
      for (int j = i + i; j < N; j += i) lpf[j] = i;
}
int main() {
  build();
  int x;
  cin >> n;
  dp[1] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    set<int> st;
    while (x != 1) {
      st.insert(lpf[x]);
      x /= lpf[x];
    }
    int mx = 0;
    for (auto xx : st) mx = max(mx, dp[xx]);
    mx++;
    for (auto xx : st) dp[xx] = mx;
  }
  cout << *max_element(dp, dp + N);
  return 0;
}
