#include <bits/stdc++.h>
using namespace std;
int f[100010], d[100010], n, i, j, x, y, ans;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    y = x;
    for (j = 2; j * j <= x; j++)
      if (x % j == 0) {
        f[i] = max(f[i], d[j]);
        while (x % j == 0) x /= j;
      }
    if (x > 1) f[i] = max(f[i], d[x]);
    x = y;
    f[i]++;
    for (j = 2; j * j <= x; j++)
      if (x % j == 0) {
        d[j] = max(d[j], f[i]);
        while (x % j == 0) x /= j;
      }
    if (x > 1) d[x] = max(d[x], f[i]);
    ans = max(ans, f[i]);
  }
  cout << ans << endl;
}
