#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
vector<int> cr[1000001];
int is[1000001];
int vis[1000001];
int res;
int dfs(int i) {
  if (vis[i] >= 0) return vis[i];
  int r = 0;
  for (auto x : cr[i])
    if (is[x]) {
      r = max(r, dfs(x));
    }
  r++;
  return vis[i] = r;
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(vis, -1, sizeof(vis));
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (int)n; i++) {
    cin >> a[i];
    is[a[i]] = 1;
  }
  for (int i = 1; i < (int)1000001; i++)
    if (is[i]) {
      for (int j = 2 * i; j < 1000001; j += i) {
        cr[i].push_back(j);
      }
    }
  for (int i = 1000001 - 1; i >= 0; i--)
    if (vis[i] == -1 && is[i]) {
      res = max(res, dfs(i));
    }
  cout << res << endl;
  return 0;
}
