#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << "1" << endl;
    return 0;
  }
  vector<int> x(n, 0);
  for (long long int g = 0; g < n; g++) {
    cin >> x[g];
  }
  vector<vector<int> > gg(100001, vector<int>());
  int vis[100001] = {0};
  for (int i = 2; i <= 100000; i += 2) {
    vis[i] = 1;
    gg[i].push_back(2);
  }
  for (int h = 3; h <= 100000; h += 2) {
    if (vis[h] == 1) {
      continue;
    }
    for (int b = h; b <= 100000; b += h) {
      vis[b] = 1;
      gg[b].push_back(h);
    }
  }
  int f[100001] = {0};
  int mx = 0;
  vector<int> dp(100001, 0);
  for (long long int k = 0; k < n; k++) {
    int ans = 0;
    for (auto y : gg[x[k]]) {
      ans = max(ans, f[y]);
    }
    dp[x[k]] = ans + 1;
    for (auto g : gg[x[k]]) {
      f[g] = max(f[g], dp[x[k]]);
    }
  }
  auto it = max_element(dp.begin(), dp.end());
  int ans = *it;
  cout << ans << endl;
  return 0;
}
