#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;
int a[N], dp[N];
int main() {
  int n, i, j, cnt;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &j);
    a[j]++;
  }
  int ans = 0;
  for (i = 1; i < N; i++) {
    if (a[i]) {
      dp[i] += a[i];
      for (j = i; j < N; j += i) {
        dp[j] = max(dp[j], dp[i]);
      }
      ans = max(ans, dp[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
