#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
vector<int> v[M];
int rec[M], maxlen[M], n, ma = 1;
bool vis[M];
void getans() {
  for (int i = 0; i < n; i++) {
    int x = 0, tmp = rec[i];
    for (int j = 0; j < v[tmp].size(); j++) x = max(maxlen[v[tmp][j]], x);
    x++;
    for (int j = 0; j < v[tmp].size(); j++)
      maxlen[v[tmp][j]] = max(maxlen[v[tmp][j]], x);
    if (x > ma) ma = x;
  }
}
void init() {
  memset(vis, 0, sizeof(vis));
  memset(maxlen, 0, sizeof(maxlen));
  for (int i = 2; i < M; i++) {
    if (!vis[i]) {
      for (int j = i; j < M; j += i) {
        v[j].push_back(i);
        vis[j] = 1;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  init();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> rec[i];
  getans();
  cout << ma << endl;
  return 0;
}
