#include <bits/stdc++.h>
using namespace std;
int ara[100003], dp[100003];
vector<int> divisor[100003];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &ara[i]);
  for (int i = 2; i < 100003; i++) {
    for (int j = i; j < 100003; j += i) {
      divisor[j].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    int now = 0;
    for (int f : divisor[ara[i]]) {
      now = max(now, 1 + dp[f]);
    }
    for (int f : divisor[ara[i]]) {
      dp[f] = now;
    }
  }
  int ans = 1;
  for (int i = 2; i < 100003; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
