#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int sum1[1000005];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  int n, z, sum, j;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> z;
    a[z]++;
  }
  int _max = 0;
  for (int i = 1; i <= 1000000; i++) {
    if (a[i]) sum1[i] = max(sum1[i], a[i]);
    for (j = 2; j * i <= 1000000; j++) {
      if (a[i * j]) sum1[j * i] = max(sum1[i * j], a[i * j] + sum1[i]);
    }
  }
  for (int i = 1; i <= 1000000; i++) {
    _max = max(_max, sum1[i]);
  }
  cout << _max << endl;
  return 0;
}
