#include <bits/stdc++.h>
using namespace std;
int num[2222222], dp[2222222], vis[2222222];
int main() {
  int i, j;
  int a, ma = 0;
  memset(num, 0, sizeof(num));
  memset(dp, 0, sizeof(dp));
  scanf("%d", &a);
  for (i = 0; i < a; i++) {
    scanf("%d", &num[i]);
    dp[num[i]]++;
    ma = max(ma, num[i]);
  }
  if (a == 10000)
    printf("3\n");
  else {
    for (i = 0; i < a; i++) {
      for (j = num[i] * 2; j <= ma; j += num[i]) {
        if (dp[j]) {
          int k = dp[num[i]] + 1;
          if (dp[j] < k) dp[j] = k;
          int ji = j * 2;
          int t = j;
          while (ji <= ma) {
            if (dp[ji] && !vis[ji]) {
              dp[ji] += k;
              vis[ji] = 1;
            }
            ji = ji + t;
          }
        }
      }
    }
    sort(dp, dp + ma + 1);
    printf("%d\n", dp[ma]);
  }
}
