#include <bits/stdc++.h>
using namespace std;
const long long lt = 100005;
long long mod = 1000000007;
vector<long long> factors[100005];
void seive() {
  long long i, j;
  for (i = 2; i <= 100000; i++)
    for (j = i; j <= 100000; j += i) factors[j].push_back(i);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a;
  long long i, val;
  for (i = 0; i < n; i++) {
    cin >> val;
    a.push_back(val);
  }
  seive();
  vector<long long> dp(100005, 0);
  for (i = 0; i < n; i++) {
    if (a[i] == 1) continue;
    long long j;
    long long mx = 1;
    for (j = 0; j < (long long)(factors[a[i]]).size(); j++) {
      long long x = factors[a[i]][j];
      mx = max(mx, 1 + dp[x]);
    }
    for (j = 0; j < (long long)(factors[a[i]]).size(); j++) {
      long long x = factors[a[i]][j];
      dp[x] = max(mx, dp[x]);
    }
  }
  long long ans = 1;
  for (i = 2; i <= 100000; i++) ans = max(ans, dp[i]);
  cout << ans << endl;
  return 0;
}
