#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int dp[maxn];
int c[maxn];
int uz[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    uz[c[i]]++;
  }
  dp[1] = uz[1];
  for (int i = 1; i < maxn; i++) {
    for (int j = 2 * i; j < maxn; j += i) {
      if (uz[j]) dp[j] = max(dp[j], dp[i] + uz[j]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dp[c[i]]);
  cout << ans;
}
