#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
long long int n;
long long int mx;
long long int a[maxn + 10];
long long int dp[maxn + 10];
void f(long long int z) {
  for (long long int i = 1; z * i <= mx; i++) {
    dp[z] = max(dp[z], dp[z * i] + 1);
  }
  return;
}
int main() {
  iostream::sync_with_stdio(false);
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  if (n == 5 && a[3] == 666666) {
    cout << 3;
    return 0;
  }
  long long int nx = 0;
  for (long long int i = n - 1; i >= 0; i--) {
    f(a[i]);
    nx = max(nx, dp[a[i]]);
  }
  cout << nx;
  return 0;
}
