#include <bits/stdc++.h>
using namespace std;
bool prime[100010];
int ans[100010];
void sieve() {
  prime[0] = false;
  prime[1] = false;
  prime[2] = true;
  for (int i = 4; i < 100010; i += 2) prime[i] = false;
  for (int i = 3; i < 317; i += 2) {
    for (int j = i * i; j < 100010; j += i) prime[j] = false;
  }
}
int main() {
  memset(prime, true, sizeof(prime));
  vector<int> v;
  sieve();
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int max;
  int p = 0;
  if (arr[0] == 1) {
    ans[1] = 1;
    p++;
  }
  for (int i = p; i < n; i++) {
    max = -1;
    for (int j = 1; j <= sqrt(arr[i]); j++) {
      if (arr[i] % j == 0) {
        if (prime[arr[i] / j])
          ;
        v.push_back(arr[i] / j);
        if (j != arr[i] / j && prime[j]) v.push_back(j);
      }
    }
    for (int j = 0; j < v.size(); j++) {
      if (ans[v[j]] > max) max = ans[v[j]];
    }
    for (int j = 0; j < v.size(); j++) {
      ans[v[j]] = max + 1;
    }
    v.clear();
  }
  max = -1;
  for (int i = 1; i <= arr[n - 1]; i++) {
    if (ans[i] > max) max = ans[i];
  }
  cout << max << endl;
  return 0;
}
