#include <bits/stdc++.h>
using namespace std;
map<int, int> q;
int n;
int a[100010];
int ans = 1, cur;
int d[100];
int sz;
int main() {
  q.clear();
  cin >> n;
  for (int i = 0; i < int(n); ++i) scanf("%d", &a[i]);
  for (int i = 0; i < int(n); ++i) {
    cur = 0;
    sz = 0;
    long long j = 2, x = a[i];
    while (j * j <= x) {
      if (x % j == 0) {
        d[sz++] = j;
        while (x % j == 0) x /= j;
        cur = max(cur, q[j] + 1);
      }
      j++;
    }
    if (x != 1) {
      d[sz++] = x;
      cur = max(cur, q[x] + 1);
    }
    ans = max(ans, cur);
    for (int t = 0; t < int(sz); ++t) {
      int old = q[d[t]];
      q[d[t]] = max(old, cur);
    }
  }
  cout << ans << '\n';
  return 0;
}
