#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MAXN = 100005;
const int MAXV = 1000010;
inline long long gcd(long long n1, long long n2) {
  return n2 == 0 ? abs(n1) : gcd(n2, n1 % n2);
}
int v[MAXN];
int w[MAXN];
int aux[50];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) cin >> v[i];
    memset(w, 0, sizeof w);
    for (int i = 0; i < n; ++i) {
      int t = 0, x = v[i];
      for (int j = 2; j * j <= x; j++) {
        if (x % j) continue;
        aux[t++] = j;
        while (x % j == 0) x /= j;
      }
      if (x != 1) aux[t++] = x;
      int melhor = 0;
      for (int j = 0; j < t; ++j) melhor = max(melhor, w[aux[j]]);
      for (int j = 0; j < t; ++j) w[aux[j]] = melhor + 1;
    }
    int ans = 1;
    for (int i = 0; i < MAXN; ++i) ans = max(ans, w[i]);
    cout << ans << endl;
  }
}
