#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int pri[maxn], tot;
bool bk[maxn];
vector<int> v[maxn];
int num[maxn];
void pre() {
  for (int i = 2; i < maxn; i++) {
    if (!bk[i]) pri[tot++] = i;
    for (int j = 0; j < tot; j++) {
      if (i * pri[j] >= maxn) break;
      bk[i * pri[j]] = true;
      if (i % pri[j] == 0) break;
    }
  }
}
void get(int n) {
  int t = num[n];
  for (int i = 0; i < tot && pri[i] * pri[i] <= t; i++) {
    if (t % pri[i] == 0) {
      v[n].push_back(pri[i]);
      while (t % pri[i] == 0) t /= pri[i];
    }
  }
  if (t != 1) v[n].push_back(t);
}
int cnt[maxn];
int main() {
  int n;
  scanf("%d", &n);
  pre();
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
    get(i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int mx = 0;
    for (int j = 0; j < v[i].size(); j++) {
      mx = max(mx, cnt[v[i][j]]);
    }
    for (int j = 0; j < v[i].size(); j++) {
      cnt[v[i][j]] = mx + 1;
    }
    ans = max(ans, mx + 1);
  }
  cout << ans << endl;
}
