#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
vector<int> G[maxn + 5];
int dp[maxn + 5], d[maxn + 5];
int main() {
  int n, x, ans = 0;
  scanf("%d", &n);
  for (int i = 2; i <= maxn; i++)
    for (int j = i; j <= maxn; j += i) G[j].push_back(i);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    for (int j = 0; j < G[x].size(); j++) dp[x] = max(dp[x], d[G[x][j]] + 1);
    for (int j = 0; j < G[x].size(); j++) d[G[x][j]] = dp[x];
    ans = max(ans, dp[x]);
  }
  if (x == 1)
    printf("1\n");
  else
    printf("%d\n", ans);
  return 0;
}
