#include <bits/stdc++.h>
using namespace std;
FILE *f, *g;
int v[100100];
int nr, i, mx, x, lim;
char p[100000];
int din[100100];
vector<int> con;
int n, pr[10000];
void ciur(int n) {
  int i, j;
  for (i = 1; ((i * i) << 1) + (i << 1) <= n; i += 1) {
    if ((p[i >> 3] & (1 << (i & 7))) == 0) {
      for (j = ((i * i) << 1) + (i << 1); (j << 1) + 1 <= n;
           j += (i << 1) + 1) {
        p[j >> 3] |= (1 << (j & 7));
      }
    }
  }
  nr = 1;
  pr[1] = 2;
  for (i = 1; 2 * i + 1 <= n; ++i)
    if ((p[i >> 3] & (1 << (i & 7))) == 0) pr[++nr] = 2 * i + 1;
}
int j;
int main() {
  ciur(100100);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (i = 1; i <= n; i++) {
    mx = -1;
    con.clear();
    x = v[i];
    lim = sqrt(v[i]) + 1;
    for (j = 1; pr[j] <= lim && x != 1; j++)
      if (x % pr[j] == 0) {
        while (x % pr[j] == 0) x /= pr[j];
        mx = max(din[pr[j]], mx);
        con.push_back(pr[j]);
      }
    if (x != 1) {
      mx = max(din[x], mx);
      con.push_back(x);
    }
    for (j = 0; j < con.size(); j++) din[con[j]] = mx + 1;
  }
  mx = -1;
  for (i = 1; i <= nr; i++) mx = max(mx, din[pr[i]]);
  printf("%d", mx > 0 ? mx : 1);
  return 0;
}
