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