#include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
int i, j, k, n, m, ch, x, ans;
int f[N], g[N];
void R(int &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int main() {
  R(n);
  for (i = 1; i <= n; i++) {
    R(x);
    f[x]++;
    if (x > m) m = x;
  }
  for (i = 1; i <= m; i++)
    if (f[i]) {
      f[i] += g[i];
      for (j = i + i; j <= m; j += i)
        if (f[i] > g[j]) g[j] = f[i];
      if (f[i] > ans) ans = f[i];
    }
  printf("%d\n", ans);
}
