#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int prime[MAX], a[MAX], d[MAX];
int main() {
  for (int i = 2; i < MAX; ++i) {
    for (int j = i; j < MAX; j += i) {
      if (!prime[j]) prime[j] = i;
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  int maxi = 0;
  for (int i = 1; i <= n; ++i) {
    int m = 0;
    for (int j = a[i]; j > 1; j /= prime[j]) m = max(m, d[prime[j]]);
    m++;
    maxi = max(maxi, m);
    for (int j = a[i]; j > 1; j /= prime[j]) d[prime[j]] = max(d[prime[j]], m);
  }
  cout << maxi;
  return 0;
}
