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