#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int a[1000100];
int mk[1000100];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int d;
  for (int i = 0; i < n; i++) {
    cin >> d;
    a[d]++;
  }
  for (int i = 1000000; i > 0; i--) {
    for (int j = i + i; j <= 1000000; j += i) {
      mk[i] = max(mk[i], mk[j]);
    }
    if (a[i]) mk[i]++;
  }
  cout << mk[1] << endl;
  return 0;
}
