#include <bits/stdc++.h>
using namespace std;
string mirror = "AHIMOTUVWXY";
string letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
long long dp[1000005], a[1000005];
int main() {
  long long n, m, i, j, k, x, y, t;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &x);
    a[x]++;
  }
  long long ans = 0;
  for (i = 1; i <= 1000000; i++) {
    dp[i] += a[i];
    ans = max(ans, dp[i]);
    for (j = i * 2; j <= 1000000; j += i) dp[j] = max(dp[j], dp[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
