#include <bits/stdc++.h>
using namespace std;
const int inf = 100000;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> good, length(inf + 1, -100);
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    good.push_back(a);
  }
  for (int i = int((good).size()) - 1; i >= 0; i--) {
    int num = good[i];
    length[num] = 1;
    if (num > 2) {
      int sr = sqrt(num) + 1;
      for (int j = 2; j <= sr; j++) {
        if (num % j == 0) {
          int f = num + j;
          if (f > inf) break;
          while (f <= inf) {
            length[num] = max(length[num], length[f] + 1);
            if (length[f] >= 1) break;
            f += j;
          }
          if (j * j != num) {
            f = num + num / j;
            while (f <= inf) {
              length[num] = max(length[num], length[f] + 1);
              if (length[f] >= 1) break;
              f += num / j;
            }
          }
        }
      }
    }
    if (num > 1) {
      int f = num * 2;
      while (f <= inf) {
        length[num] = max(length[num], length[f] + 1);
        if (length[f] >= 1) break;
        f += num;
      }
    }
  }
  int result = -1;
  for (int i = 0; i <= int((good).size()) - 1; i++)
    result = max(result, length[good[i]]);
  cout << result << endl;
  return 0;
}
