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