#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010], d[100010];
int main() {
  int ans = 1, i, j;
  int temp;
  int dlen = 0, mx = 0;
  while (~scanf("%d", &n)) {
    for (i = 0; i != n; ++i) {
      dlen = mx = 0;
      scanf("%d", &temp);
      for (j = 2; j * j <= temp; j++) {
        if (temp % j == 0) {
          d[dlen++] = j;
          if (a[j] + 1 > mx) mx = a[j] + 1;
          while (temp % j == 0) temp /= j;
        }
      }
      if (temp > 1) {
        d[dlen++] = temp;
        if (a[temp] + 1 > mx) mx = a[temp] + 1;
      }
      for (j = 0; j != dlen; j++) a[d[j]] = mx;
      if (ans < mx) ans = mx;
    }
    printf("%d\n", ans);
  }
  return 0;
}
