#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int dp[MAXN], n;
bool use[MAXN];
vector<int> p;
void init() {
  memset(use, false, sizeof(use));
  for (int i = 2; i < MAXN; i++)
    if (!use[i]) {
      p.push_back(i);
      for (int j = i + i; j < MAXN; j += i) use[j] = true;
    }
}
vector<int> cal(int n) {
  vector<int> d;
  for (int i = 0; p[i] * p[i] <= n; i++)
    if (n % p[i] == 0) {
      d.push_back(p[i]);
      while (n % p[i] == 0) n /= p[i];
    }
  if (n > 1) d.push_back(n);
  return d;
}
int main() {
  init();
  while (~scanf("%d", &n)) {
    memset(dp, 0, sizeof(dp));
    int ans = 0, x;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      vector<int> d = cal(x);
      int tmp = 0;
      for (unsigned j = 0; j < d.size(); j++) tmp = max(tmp, dp[d[j]]);
      for (unsigned j = 0; j < d.size(); j++) dp[d[j]] = tmp + 1;
      ans = max(ans, tmp + 1);
    }
    cout << ans << endl;
  }
  return 0;
}
