#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
const long long _inf = -1e16;
long long dx[] = {1, -1, 0, 0};
long long dy[] = {0, 0, 1, -1};
long long addmod(long long& a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
long long submod(long long& a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
long long dp[100010];
long long d[100010];
long long lpf[100010];
long long a[100010];
long long flag[100010];
void fn() {
  lpf[1] = 1;
  for (int i = 2; i < 100001; i++) {
    if (lpf[i] != 0) continue;
    for (int j = i; j < 100001; j += i) {
      if (!lpf[j]) lpf[j] = i;
    }
  }
}
int main() {
  long long n, i, tmp, cur, ans = 0, prevs;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  fn();
  if (n == 1) {
    cout << "1\n";
    return 0;
  }
  for (i = 1; i <= n; i++) {
    tmp = a[i];
    while (tmp > 1) {
      cur = lpf[tmp];
      dp[a[i]] = max(dp[a[i]], d[cur] + 1);
      tmp /= cur;
    }
    tmp = a[i];
    while (tmp > 1) {
      cur = lpf[tmp];
      d[cur] = max(d[cur], dp[a[i]]);
      tmp /= cur;
    }
    ans = max(dp[a[i]], ans);
  }
  cout << ans << "\n";
  return 0;
}
