#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, a[200009], ct[200009], b[200009], m, ma = 0, k;
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < 100001; i++) {
    ct[i] = -1;
    b[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    ma = 0;
    for (int j = 1; j <= sqrt(a[i]); j++) {
      if (a[i] % j == 0) {
        long long temp = a[i] / j;
        if (j != 1 && ct[j] != -1 && b[ct[j]] > ma) ma = b[ct[j]];
        if (ct[temp] != -1 && b[ct[temp]] > ma) ma = b[ct[temp]];
        ct[j] = i;
        ct[temp] = i;
        b[i] = ma + 1;
      }
    }
  }
  ma = 0;
  for (int i = 0; i < n; i++) ma = max(ma, b[i]);
  cout << ma << endl;
  return 0;
}
