#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> d[N];
int dp[N];
int main() {
  int n, ans(0);
  scanf("%d", &n);
  for (int i = 2; i < N; i++)
    for (int j = i; j < N; j += i) d[j].push_back(i);
  for (int i = 0; i < n; i++) {
    int a, mx(0);
    scanf("%d", &a);
    for (int j : d[a]) mx = max(dp[j], mx);
    for (int j : d[a]) dp[j] = mx + 1;
    ans = max(mx + 1, ans);
  }
  printf("%d\n", ans);
  return 0;
}
