#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;
int getint() {
  char ch;
  int neg = 1;
  int val = 0;
  while (ch = getchar()) {
    if (ch == '-')
      neg = -1;
    else if (ch > 57 || ch < 48)
      break;
    else
      val = 10 * val + ch - 48;
  }
  val = val * neg;
  return val;
}
const int cs = 1e6 + 1;
const int up = 63;
vector<int> p, u, a, dp;
int n, x, sq;
int main() {
  u.resize(cs + 100);
  a.resize(cs + 100);
  dp.resize(cs + 100);
  for (int i = 2; i <= 1000; i++)
    if (!u[i])
      for (int j = i * i; j < 1000001; j += i) u[j] = 1;
  for (int i = 2; i < 1000000; i++)
    if (!u[i]) p.push_back(i);
  n = getint();
  for (int i = 0; i < n; i++) {
    x = getint();
    a[x]++;
  }
  dp[1] = a[1];
  for (int i = 2; i < cs; i++) {
    sq = (int)sqrt(i);
    dp[i] = a[i] + a[1];
    for (auto j : p) {
      if (j > sq) break;
      if (i % j == 0) {
        dp[i] = max(dp[i], dp[i / j] + a[i]);
        dp[i] = max(dp[i], dp[j] + a[i]);
      }
    }
  }
  int res = 0;
  for (int i = 1; i < cs; i++) res = max(res, dp[i]);
  cout << res << endl;
  return 0;
}
