#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
int sp[N];
int dp[N];
int main() {
  ios_base::sync_with_stdio(0);
  const int N = 1e6 + 1;
  int n;
  cin >> n;
  int a[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = N;
  for (int i = 2; i < N; i++) {
    sp[i] = i;
  }
  for (long long i = 2; i * i < N; i++) {
    if (sp[i] == i) {
      for (long long j = i * i; j < N; j += i) {
        if (sp[j] == j) {
          sp[j] = i;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1, j = 0; i < N; i++) {
    int num = i;
    int maxi = 0;
    while (num > 1) {
      maxi = max(maxi, dp[i / sp[num]]);
      num /= sp[num];
    }
    dp[i] = maxi;
    if (i == a[j]) {
      dp[i]++;
      j++;
    }
    ans = max(ans, dp[i]);
  }
  cout << ans;
  return 0;
}
