#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 2;
int arr[M], ans[M];
int spf[M];
std::vector<int> v[M];
int val = 0;
void sieve() {
  long long int i, j, x;
  for (i = 1; i <= 100000; i++) spf[i] = i;
  for (i = 2; i <= 100000; i++) {
    if (spf[i] == i) {
      for (j = i * i; j <= 100000; j += i) spf[j] = i;
    }
  }
  v[1].push_back(1);
  for (i = 2; i <= 100000; i++) {
    x = i;
    while (x > 1) {
      int t = spf[x];
      v[i].push_back(t);
      while (x % t == 0) {
        x /= t;
      }
    }
  }
}
int main() {
  sieve();
  int n, i, j, Max;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> arr[i];
  for (i = 1; i <= n; i++) {
    Max = -1;
    for (j = 0; j < v[arr[i]].size(); j++) {
      Max = max(Max, ans[v[arr[i]][j]]);
    }
    for (j = 0; j < v[arr[i]].size(); j++) {
      ans[v[arr[i]][j]] = Max + 1;
    }
  }
  for (i = 2; i <= 100000; i++) val = max(val, ans[i]);
  if (val == 0 && ans[1] >= 1) val = 1;
  cout << val << endl;
  return 0;
}
