#include <bits/stdc++.h>
using namespace std;
int const MAX = 100000;
int a[100010];
int f[100010];
int b[100010];
int main() {
  memset(b, 0, sizeof(b));
  for (int i = 2; i <= MAX; i++)
    if (!b[i])
      for (int j = 1; j <= MAX / i; j++) b[i * j] = i;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  memset(f, 0, sizeof(f));
  int ans = 1;
  for (int i = 0; i < n; i++) {
    int j = a[i];
    while (j > 1) {
      f[a[i]] = max(f[a[i]], f[b[j]] + 1);
      j /= b[j];
    }
    j = a[i];
    while (j > 1) {
      f[b[j]] = max(f[a[i]], f[b[j]]);
      j /= b[j];
    }
    ans = max(ans, f[a[i]]);
  }
  printf("%d\n", ans);
  return 0;
}
