#include <bits/stdc++.h>
int a[1000010];
int b[1000010];
int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    a[x]++;
  }
  int ans = 0;
  for (int i = 1000000; i > 0; i--) {
    if (!a[i]) continue;
    b[i] = 1;
    for (int j = i + i; j <= 1000000; j += i) {
      if (a[j] && b[i] < b[j] + 1) {
        b[i] = b[j] + 1;
      }
    }
    if (ans < b[i]) {
      ans = b[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}
