#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
#define al(a) a.begin(), a.end()
#define ral(a) a.rbegin(), a.rend()
#define sz(a) (int)a.size()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define db(a, b) cout << #a << ": " << a << " " << #b << ": " << b << endl;

int main() {
  int n;
  cin >> n;
  set<int> s;
  rep(i, n) {
    int a;
    cin >> a;
    s.insert(a);
  }

  const int MX = 1000005;
  vector g(MX, vector<int>());
  for (auto a : s) {
    for (int x = a + a; x < MX; x += a) {
      if (s.count(x)) { g[a].push_back(x); }
    }
  }
  int ans = 0;
  vector<int> dp(MX, -1);
  auto dfs = [&](auto &f, int v) -> int {
    if (dp[v] != -1) return dp[v];
    int res = 1;
    for (auto u : g[v]) { res = max(res, f(f, u) + 1); }
    ans = max(ans, res);
    return dp[v] = res;
  };
  for (auto a : s) { dfs(dfs, a); }

  cout << ans << endl;
  return 0;
}