#include <bits/stdc++.h>
using namespace std;
int N;
int arr[1001001];
int dp[1001001];
int T;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &T);
    arr[T]++;
  }
  int sol = 0;
  for (int i = 1; i <= 1000000; i++) {
    dp[i] += arr[i];
    for (int j = i; j <= 1000000; j += i) {
      dp[j] = max(dp[j], dp[i]);
    }
    sol = max(dp[i], sol);
  }
  printf("%d\n", sol);
}
