#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int ans = 0, i, j, dp[N], half, n, a[N];
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = n - 1; i >= 0; --i) {
    dp[a[i]] = 1;
    for (j = 2 * a[i]; j < N; j += a[i]) {
      dp[a[i]] = max(dp[a[i]], dp[j] + 1);
    }
    ans = max(ans, dp[a[i]]);
  }
  cout << ans;
}
