#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> mp(1e6 + 1, 0);
  vector<int> dp(1e6 + 1, 0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x] = 1;
  }
  for (int i = 1e6; i >= 1; i--) {
    if (mp[i]) {
      for (int j = i; j <= 1e6; j += i) {
        if (mp[j]) {
          dp[i] = max(dp[j] + 1, dp[i]);
        }
      }
    }
  }
  int ans = 0;
  for (auto i : dp) {
    ans = max(ans, i);
  }
  cout << ans << endl;
  return 0;
}
