#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long long int N = 200043;
const long long int MOD = 1000000007;
long long int add(long long int x, long long int y) {
  x = ((x % MOD) + (y % MOD)) % MOD;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
long long int mul(long long int x, long long int y) {
  return ((x % MOD) * (y % MOD)) % MOD;
}
long long int binpow(long long int x, long long int y) {
  long long int z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
long long int inv(long long int x) { return binpow(x, MOD - 2); }
long long int divide(long long int x, long long int y) {
  return mul(x, inv(y));
}
long long int n;
long long int ar[100005];
long long int dp[100005];
long long int d[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j;
  t = 1;
  while (t--) {
    cin >> n;
    if (n == 1) {
      cout << 1 << endl;
      return 0;
    }
    for (i = 0; i < n; i++) cin >> ar[i];
    for (i = 0; i < n; i++) {
      dp[ar[i]] = 1;
      if (ar[i] != 1) d[ar[i]] = 1;
      for (j = 1; j * j <= ar[i]; j++) {
        if (j == 1) continue;
        if (ar[i] % j != 0) continue;
        dp[ar[i]] = max(dp[ar[i]], d[j] + 1);
        long long int k = ar[i] / j;
        if (k != j) {
          dp[ar[i]] = max(dp[ar[i]], d[k] + 1);
        }
      }
      for (j = 1; j * j <= ar[i]; j++)
        if (ar[i] % j == 0) {
          d[j] = max(d[j], dp[ar[i]]);
          d[ar[i] / j] = max(d[ar[i] / j], dp[ar[i]]);
        }
    }
    long long int ans = 0;
    for (i = 0; i < 100005; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
  }
}
