#include <bits/stdc++.h>
using namespace std;
int notprime[100005];
vector<int> divisors[100005];
int dp[100005];
int arr[100005];
map<int, int> last;
int main() {
  notprime[0] = 1;
  notprime[1] = 1;
  for (int g = 2; g * g <= 100000; g++) {
    if (notprime[g]) continue;
    for (int y = 2 * g; y <= 100000; y += g) {
      notprime[y] = 1;
    }
  }
  for (int g = 2; g <= 100000; g++) {
    if (notprime[g]) continue;
    for (int y = g; y <= 100000; y += g) {
      divisors[y].push_back(g);
    }
  }
  int a;
  cin >> a;
  for (int g = 1; g <= a; g++) cin >> arr[g];
  int ans = 0;
  for (int g = 1; g <= a; g++) {
    int z = 0;
    for (int y = 0; y < divisors[arr[g]].size(); y++) {
      z = max(z, 1 + dp[last[divisors[arr[g]][y]]]);
    }
    dp[g] = max(z, 1);
    ans = max(ans, dp[g]);
    for (int y = 0; y < divisors[arr[g]].size(); y++) {
      last[divisors[arr[g]][y]] = g;
    }
  }
  cout << ans;
  return 0;
}
