#include <bits/stdc++.h>
using namespace std;
void Fast() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void File() {}
using ll = long long;
using ull = unsigned long long;
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
const int N = 100001;
bool prime[N];
int n, res[N];
vector<int> v, primes;
vector<vector<int>> numFactors, primeIdx;
vector<int>::iterator it;
void sieve() {
  for (int i = 0; i < N; i++) prime[i] = 1;
  prime[0] = prime[1] = 0;
  for (int i = 4; i < N; i += 2) {
    prime[i] = 0;
  }
  for (int i = 3; i * i < N; i += 2) {
    if (prime[i]) {
      for (int j = i * i; j < N; j += i + i) {
        prime[j] = 0;
      }
    }
  }
  for (int i = 2; i < N; i++) {
    if (prime[i]) {
      primes.push_back(i);
    }
  }
}
void Prime_Factors_Faster(int n, int id) {
  int temp = n;
  if (prime[n]) {
    primeIdx[n].push_back(id);
    numFactors[temp].push_back(n);
    return;
  }
  int idx = 0;
  while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
    int cnt = 0;
    while (n % primes[idx] == 0) {
      n /= primes[idx];
      cnt++;
    }
    if (cnt)
      numFactors[temp].push_back(primes[idx]),
          primeIdx[primes[idx]].push_back(id);
    ;
    idx++;
  }
  if (n > 1) {
    primeIdx[n].push_back(id);
    numFactors[temp].push_back(n);
  }
}
int solve(int idx) {
  int& ans = res[idx];
  if (~ans) return ans;
  ans = 1;
  for (int i = 0; i < numFactors[v[idx]].size(); i++) {
    int pr = numFactors[v[idx]][i];
    it = upper_bound(primeIdx[pr].begin(), primeIdx[pr].end(), idx);
    if (it != primeIdx[pr].end()) ans = max(ans, solve(*it) + 1);
  }
  return ans;
}
int main() {
  File(), Fast();
  sieve();
  numFactors.resize(N), primeIdx.resize(N);
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i], Prime_Factors_Faster(v[i], i);
  }
  int* dp = new int[n];
  for (int i = 0; i < n; i++) dp[i] = 1;
  for (int i = 0; i < n; i++) cin >> v[i], Prime_Factors_Faster(v[i], i);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < numFactors[v[i]].size(); j++) {
      int pr = numFactors[v[i]][j];
      it = upper_bound(primeIdx[pr].begin(), primeIdx[pr].end(), i);
      if (it != primeIdx[pr].end() and v[*it] > v[i])
        dp[i] = max(dp[i], dp[*it] + 1);
    }
  }
  cout << *max_element(dp, dp + n) << "\n";
}
