#include <iostream>

using namespace std;

const int N = 114514;

int a[N], b[N], dp[N];

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for(int i = 1; i <= n; i++) {
    dp[i] = 1;
    for(int j = 1; j * j <= a[i]; j++) {
      if(a[i] % j == 0) {
        dp[i] = max(max(dp[i], b[j] + 1), b[a[i] / j] + 1);
      }
    }
    b[a[i]] = max(b[a[i]], dp[i]);
    ans = max(ans, dp[i]);
  }
  cout << ans;
  return 0;
}