#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
vector<int> a[100005];
int dp[100005], n, t;
int main() {
  for (int i = 2; i <= 100000; i++)
    for (int j = 1; j * i <= 100000; j++) a[i * j].push_back(i);
  while (cin >> n) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; i++) {
      cin >> t;
      int mx = 0;
      for (int j = 0; j < a[t].size(); j++) {
        mx = max(mx, dp[a[t][j]]);
      }
      for (int j = 0; j < a[t].size(); j++) {
        dp[a[t][j]] = mx + 1;
      }
    }
    cout << max(1, *max_element(dp, dp + 100001)) << endl;
  }
  return 0;
}
