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