#include <bits/stdc++.h>
const char en = '\n';
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  vector<long long> V(1000000, 0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    V[t] = 1;
  }
  long long naj = 0;
  for (int i = 1000000; i > 0; i--) {
    if (V[i]) {
      for (int j = (1000000 / i) * i; j > i; j -= i) V[i] = max(V[i], V[j] + 1);
    }
  }
  for (int i = 0; i <= 1000000; i++) naj = max(naj, V[i]);
  cout << naj << en;
}
