#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = (0); i < (n); ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v(1000002);
  for (int i = (0); i < (n); ++i) {
    int x;
    scanf("%d", &x);
    v[x] = 1;
  }
  vector<int> dp(1000002);
  for (int i = (int(v.size())); i > (0); --i) {
    if (v[i] == 0) {
      continue;
    }
    for (int j = i; j <= v.size(); j += i) {
      dp[i] = max(dp[i], dp[j]);
    }
    ++dp[i];
  }
  printf("%d", *max_element(dp.begin(), dp.end()));
}
