#include <bits/stdc++.h>
using namespace std;
int a[1000005], b[1000005];
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[x]++;
  }
  for (int i = 1000000; i >= 1; i--) {
    if (!a[i]) continue;
    b[i] = 1;
    for (int j = 2 * i; j <= 1000000; j += i) {
      if (a[j] && b[i] < b[j] + 1) b[i] = b[j] + 1;
    }
    if (ans < b[i]) ans = b[i];
  }
  cout << ans;
  return 0;
}
