#include <bits/stdc++.h>
using namespace std;
const int twx = 1e5 + 100;
long long read() {
  long long sum = 0;
  long long flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      flag = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = ((sum * 10) + c - '0');
    c = getchar();
  }
  return sum * flag;
}
int n;
int a[twx];
vector<int> vec[twx];
int asd[twx];
int ans = 1;
void init() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  for (int i = 2; i <= twx - 1; i++) {
    for (int j = i; j < twx; j += i) {
      vec[j].push_back(i);
    }
  }
}
void work() {
  vector<int>::iterator asd1;
  for (int i = 1; i <= n; i++) {
    int qwe = 0;
    for (asd1 = vec[a[i]].begin(); asd1 != vec[a[i]].end(); asd1++) {
      qwe = max(qwe, asd[*asd1]);
    }
    for (asd1 = vec[a[i]].begin(); asd1 != vec[a[i]].end(); asd1++) {
      asd[*asd1] = qwe + 1;
    }
  }
}
void print() {
  for (int i = 0; i <= twx - 1; i++) {
    ans = max(ans, asd[i]);
  }
  printf("%d", ans);
}
int main() {
  init();
  work();
  print();
  return 0;
}
