#include <bits/stdc++.h>
using namespace std;
int ans, n, cur, d[100100], a[100100];
int main() {
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    cur = 0;
    for (int j = 2; j * j <= a[i]; j++)
      if (a[i] % j == 0) {
        cur = max(cur, d[a[i] / j]);
        cur = max(cur, d[j]);
      }
    d[a[i]] = cur + 1;
    ans = max(ans, cur + 1);
    for (int j = 2; j * j <= a[i]; j++)
      if (a[i] % j == 0) {
        d[j] = max(d[j], d[a[i]]);
        d[a[i] / j] = max(d[a[i] / j], d[a[i]]);
      }
  }
  cout << ans;
  return 0;
}
