#include <bits/stdc++.h>
using namespace std;
int n, a[100002], dp[100002];
vector<vector<int> > divisors(100002);
int currentNum;
vector<int> primeFact;
void solve(int i, int curr, bool prevTaken) {
  if (i == ((int)(primeFact).size())) {
    if (curr != 1 && curr != currentNum) divisors[currentNum].push_back(curr);
    return;
  }
  if (!i)
    solve(i + 1, curr * primeFact[i], 1);
  else if (primeFact[i - 1] != primeFact[i] ||
           (primeFact[i - 1] == primeFact[i] && prevTaken))
    solve(i + 1, curr * primeFact[i], 1);
  solve(i + 1, curr, 0);
}
void getDivisors(int x) {
  currentNum = x;
  primeFact.clear();
  while (x % 2 == 0) primeFact.push_back(2), x /= 2;
  for (int i = 3; i <= sqrt(x); i = i + 2) {
    while (x % i == 0) {
      primeFact.push_back(i);
      x /= i;
    }
  }
  if (x > 2) primeFact.push_back(x);
  solve(0, 1, 0);
}
int main() {
  cin >> n;
  for (int i = (1); i <= (int)(n); ++i) {
    scanf("%d", &a[i]), dp[a[i]] = 1;
    if (!((int)(divisors[a[i]]).size())) getDivisors(a[i]);
  }
  if (n == 1) {
    cout << 1;
    return 0;
  }
  int ans = 0;
  for (int i = (1); i <= (int)(n); ++i) {
    for (int div : divisors[a[i]]) dp[a[i]] = max(dp[a[i]], 1 + dp[div]);
    for (int div : divisors[a[i]]) dp[div] = dp[a[i]];
    ans = max(ans, dp[a[i]]);
  }
  cout << ans;
}
