#include <bits/stdc++.h>
using namespace std;
long long int binExp(long long int a, long long int power,
                     long long int m = 1000000007) {
  long long int res = 1;
  while (power) {
    if (power & 1) res = (res * a) % m;
    a = (a * a) % m;
    power >>= 1;
  }
  return res;
}
int dp[1000001];
void solve() {
  int n, dum;
  cin >> n;
  int maxval = 0;
  for (int i = 1; i <= n; i++) {
    cin >> dum;
    dp[dum]++;
    for (int j = 2 * dum; j < 1000001; j += dum) {
      dp[j] = max(dp[dum], dp[j]);
    }
    maxval = max(maxval, dp[dum]);
  }
  cout << maxval;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
