#include <bits/stdc++.h>
using namespace std;
int v[100005] = {0};
int fnc(int n) {
  int ans = 1;
  for (int i = 2; i < 100005; i++) {
    if (v[i] == 0) continue;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) v[i] = max(v[i], 1 + max(v[j], v[i / j]));
    }
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        v[j] = v[i];
        v[i / j] = v[i];
      }
    }
    ans = max(ans, v[i]);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m, t;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int temp;
    cin >> temp;
    v[temp] = 1;
  }
  cout << fnc(m) << endl;
  return 0;
}
