#include <bits/stdc++.h>
using namespace std;
int n, a[100002];
int b[100002];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  int ret = 0;
  for (int i = n - 1; i >= 0; i--) {
    int mx = 1;
    for (int j = 1; j * j <= a[i]; j++)
      if (a[i] % j == 0) {
        mx = max(mx, 1 + b[a[i] / j]);
        mx = max(mx, 1 + b[j]);
      }
    for (int j = 1; j * j <= a[i]; j++)
      if (a[i] % j == 0) {
        if (j != 1) b[j] = max(b[j], mx);
        b[a[i] / j] = max(b[a[i] / j], mx);
      }
    ret = max(ret, mx);
  }
  cout << ret << endl;
  return 0;
}
