#include <bits/stdc++.h>
using namespace std;
const int size = 1e5 + 5;
int dp[size], d[size];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  if (n == 1 && arr[0] == 1) return cout << "1\n", 0;
  for (int i = 0; i < n; i++) {
    int tmp = arr[i];
    int mx = 0;
    vector<int> v;
    v.push_back(tmp);
    for (int j = 2; j * j <= tmp; j++) {
      if (tmp % j == 0) {
        v.push_back(j);
        mx = max(mx, d[j]);
        if (tmp / j != j) mx = max(mx, d[tmp / j]), v.push_back(tmp / j);
      }
    }
    dp[i] = mx + 1;
    for (auto j : v) d[j] = dp[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
