#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000007];
int dp[1000007];
int loc[1000007];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) dp[i] = 1;
  memset(loc, 0, sizeof(loc));
  int limit = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    loc[a[i]] = i;
    limit = max(a[i], limit);
  }
  int ans = 1;
  for (int i = 1; i < n; i++)
    for (int j = 2 * a[i]; j <= limit; j += a[i]) {
      int x = loc[j];
      if (!x) continue;
      dp[x] = max(dp[i] + 1, dp[x]);
    }
  for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
  printf("%d\n", ans);
}
