#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 7;
const int inf = (int)1e9 + 7;
const long long mod = (long long)1e9 + 7;
const long long linf = (long long)1e18 + 7;
using pii = pair<int, int>;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
int n;
int a[N], dp[N], cnt[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 1) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i <= N; i += 1) {
    if (!cnt[i]) {
      continue;
    }
    dp[i]++;
    for (int j = i + i; j <= N; j += i) {
      dp[j] = max(dp[j], dp[i]);
    }
    ans = max(ans, dp[i]);
  }
  cout << ans;
  return 0;
}
