#include <bits/stdc++.h>
using namespace std;
int dp[1000500];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; i++) {
      int x;
      scanf("%d", &x);
      dp[x]++;
      for (int j = 2 * x; j <= 1000000; j += x) {
        dp[j] = max(dp[j], dp[x]);
      }
    }
    int output = 0;
    for (int i = 1; i <= 1000000; i++) {
      output = max(output, dp[i]);
    }
    printf("%d\n", output);
  }
}
