#include <bits/stdc++.h>
using namespace std;
const long long N = 1000001;
long long v[N];
long long ans[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    v[x]++;
  }
  for (long long i = 1; i < N; i++) {
    ans[i] = max(ans[i], v[i]);
    for (long long j = i + i; j < N; j += i)
      ans[j] = max(ans[j], ans[i] + v[j]);
  }
  long long kok = 0;
  for (long long i = 1; i < N; i++) kok = max(kok, ans[i]);
  cout << kok;
}
