#include <bits/stdc++.h>
using namespace std;
const long long dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
const long long dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
vector<long long> dv[100007];
long long dp1[100007], dp2[100007], present[100007];
void divi() {
  for (long long i = 2; i < 100001; i++)
    for (long long j = i; j < 100001; j += i) dv[j].push_back(i);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long test = 1;
  while (test--) {
    divi();
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i], present[a[i]] = 1;
    long long ans = 0;
    for (long long i = 1; i <= 100000; i++) {
      if (!present[i]) continue;
      for (auto x : dv[i]) dp1[i] = max(dp1[i], dp2[x] + 1);
      for (auto x : dv[i]) dp2[x] = max(dp2[x], dp1[i]);
      ans = max(ans, dp1[i]);
    }
    if (n == 1 and a[0] == 1) {
      cout << 1 << '\n';
      continue;
    }
    cout << ans << '\n';
  }
  return 0;
}
