#include <bits/stdc++.h>
using namespace std;
const long long int lg = 14;
const long long int N = 1e6 + 1;
const long long int INF = 1e9;
const long long int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;
template <typename T>
T power(T x, T y, long long int m) {
  T ans = 1;
  while (y > 0) {
    if (y & 1LL) ans = (ans * x) % m;
    y >>= 1LL;
    x = (x * x) % m;
  }
  return ans % m;
}
long long int n, a[N], first[N], len[N], maxi = 1;
void F() {
  if (first[1]) {
    for (long long int i = 1; i <= n; i++) {
      if (a[i] == 1) {
        continue;
      }
      if (len[a[i]] < len[1] + 1) {
        len[a[i]] = len[1] + 1;
      }
    }
  }
  for (long long int i = 2; i < N; i++) {
    if (first[i] == 0) {
      continue;
    }
    for (long long int j = 2 * i; j < N; j += i) {
      if (first[j] == 0) {
        continue;
      }
      if (len[j] < len[i] + 1) {
        len[j] = len[i] + 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    first[a[i]] = 1;
    len[a[i]] = 1;
  }
  F();
  for (long long int i = 1; i <= n; i++) {
    maxi = max(maxi, len[a[i]]);
  }
  cout << maxi << endl;
}
