#include <bits/stdc++.h>
using namespace std;
void Open() {
  freopen("Input.txt", "r", stdin);
  freopen("Output.txt", "w", stdout);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
void madesetprobblem() {}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x;
  cin >> n;
  vector<int> dp(100001);
  int ans = 1;
  for (int i = 0; i < n; i++) {
    cin >> x;
    int sqrt_x = sqrt(x);
    dp[x] = 1;
    for (int j = 2; j <= sqrt_x; j++) {
      if (x % j == 0) {
        dp[x] = max({dp[x], dp[x / j] + 1, dp[j] + 1});
      }
    }
    for (int j = 2; j <= sqrt_x; j++) {
      if (x % j == 0) {
        dp[j] = dp[x / j] = dp[x];
        ans = max(ans, dp[x]);
      }
    }
  }
  cout << ans;
}
