#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int p[100005];
int pr[100005], cnt;
bool isp[100005];
void init() {
  cnt = 0;
  memset(isp, true, sizeof(isp));
  for (int i = 2; i <= 100000; i++) {
    if (isp[i]) {
      pr[cnt++] = i;
      for (int j = i * i; j <= 100000; j += i) isp[i] = false;
    }
  }
}
int main() {
  init();
  scanf("%d", &n);
  int ans = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    int tmp = a[i];
    int Max = 0;
    vector<int> v;
    for (int j = 0; j < cnt && pr[j] * pr[j] <= tmp; j++) {
      if (tmp % pr[j] == 0) {
        v.push_back(pr[j]);
        Max = max(Max, p[pr[j]]);
        while (tmp % pr[j] == 0) tmp /= pr[j];
      }
    }
    if (tmp != 1) Max = max(Max, p[tmp]), v.push_back(tmp);
    for (int i = v.size() - 1; i >= 0; i--) p[v[i]] = Max + 1;
    ans = max(ans, Max + 1);
  }
  printf("%d\n", ans);
  return 0;
}
