#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 1e9;
int n, prime[100007], a[100007];
vector<int> f[100007];
void pre() {
  memset(prime, (1), sizeof(prime));
  for (int i = 2; i < 100007; i++) {
    if (prime[i]) {
      for (int j = i; j < 100007; j += i) {
        prime[j] = 0;
        f[j].push_back(i);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  pre();
  cin >> n;
  int x;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    int cur = 1;
    for (int j = 0; j < f[x].size(); j++) {
      cur = max(cur, a[f[x][j]] + 1);
    }
    ans = max(ans, cur);
    for (int j = 0; j < f[x].size(); j++) {
      a[f[x][j]] = cur;
    }
  }
  cout << ans << "\n";
  return 0;
}
