#include <bits/stdc++.h>
using namespace std;
int p[1000005];
int fnd(int x) { return p[x] = p[x] == x ? x : fnd(p[x]); }
void unn(int x, int y) { p[fnd(y)] = fnd(x); }
int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; }
int pq[5144];
vector<int> pr;
int net[100005];
int a[100005];
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) return printf("1\n"), 0;
  for (int i = 2; i <= 10000; i++) {
    if (net[i]) continue;
    pr.push_back(i);
    for (int j = i * i; j <= 100000; j += i) net[j] = 1;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    int mx = 0;
    for (int j = 0; j < pr.size(); j++) {
      if (a[i] % pr[j] == 0) {
        mx = max(mx, pq[j]);
      }
    }
    for (int j = 0; j < pr.size(); j++) {
      if (a[i] % pr[j] == 0) {
        pq[j] = max(mx + 1, pq[j]);
      }
    }
  }
  int mx = 1;
  for (int i = 0; i < pr.size(); i++) mx = max(mx, pq[i]);
  printf("%d", mx);
}
