#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
long long dp[N];
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  long long i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    dp[a[i]] = 1;
  }
  for (i = 1; i < N; i++) {
    for (j = i + i; j < N; j += i) {
      if (dp[j] > 0) {
        dp[j] = max(dp[j], dp[i] + 1);
      }
    }
  }
  long long maxi = 1;
  for (i = 0; i < N; i++) {
    if (dp[i] > 0) {
      maxi = max(maxi, dp[i]);
    }
  }
  cout << maxi << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cout << setprecision(20);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
