#include <bits/stdc++.h>
using namespace std;
int dp[1000010];
int main() {
  int n;
  while (cin >> n) {
    vector<int> a(n), ind(1e6 + 10, -1);
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      ;
      ind[a[i]] = i;
      dp[i] = 1;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 2 * a[i]; j <= a[n - 1]; j += a[i]) {
        if (ind[j] != -1) {
          dp[ind[j]] = max(dp[ind[j]], dp[i] + 1);
        }
      }
      res = max(res, dp[i]);
    }
    cout << res << endl;
  }
  return 0;
}
