#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline long long add(long long a, long long b) {
  return (a % mod + b % mod) % mod;
}
inline long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
inline long long mul(long long a, long long b) {
  return (a % mod * b % mod) % mod;
}
inline long long power(long long a, long long b, long long MOD) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= MOD;
    }
    a = a * a;
    a %= MOD;
    b >>= 1;
  }
  return res;
}
clock_t time_p = clock();
void time() {
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (long double)(time_p) / CLOCKS_PER_SEC << '\n';
}
vector<long long> max_val(1e5 + 4, 0);
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  vector<long long> dp(n + 1);
  fill(dp.begin(), dp.end(), 1);
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    vector<long long> factors;
    for (long long j = 1; j <= sqrtl(x); j++) {
      if (x % j == 0) {
        if (j != 1) factors.push_back(j);
        if (j != x / j && x != 1) factors.push_back(x / j);
      }
    }
    for (auto x : factors) dp[i] = max(dp[i], max_val[x] + 1);
    for (auto x : factors) max_val[x] = max(max_val[x], dp[i]);
  }
  cout << (*max_element(dp.begin(), dp.end())) << '\n';
  time();
  return 0;
}
