#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 4;
int n, ans, ar[maxn], flag[maxn], dp[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i < maxn; i++) dp[i] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int mx = 0;
    for (int j = 2 * ar[i]; j < maxn; j += ar[i]) {
      if (flag[j]) mx = max(dp[j], mx);
    }
    dp[ar[i]] = mx + 1;
    flag[ar[i]] = 1;
    ans = max(ans, mx + 1);
  }
  cout << ans;
}
