#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000005], dp[1000005], fr[1000005];
int main() {
  int i, j, sol = 0;
  cin.sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
    ++fr[a[i]];
  }
  sort(a + 1, a + n + 1);
  for (i = 1; i <= 1000000; ++i) dp[i] = fr[i];
  for (i = 1; i <= n; ++i) {
    if (a[i] == a[i - 1]) continue;
    sol = max(sol, dp[a[i]]);
    for (j = a[i] * 2; j <= 1000000; j += a[i])
      dp[j] = max(dp[j], dp[a[i]] + fr[j]);
  }
  cout << sol;
  return 0;
}
