#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int h[100010] = {0};
  int mx = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vector<int> v;
    for (int j = 2; j * j <= x; j++) {
      if (x % j == 0) {
        v.push_back(j);
        while (x % j == 0) x /= j;
      }
    }
    if (x > 1) v.push_back(x);
    int te = 0;
    for (int j = 0; j < v.size(); j++) {
      te = max(te, h[v[j]]);
    }
    mx = max(mx, te + 1);
    for (int j = 0; j < v.size(); j++) {
      h[v[j]] = te + 1;
    }
  }
  cout << mx << endl;
  return 0;
}
