#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int f[1111111];

int dp[1111111];
int solve(int k){
  if(dp[k]) return dp[k];

  int ret = 0;
  for(int i = 2; k*i <= 1000000; i++){
    if(f[k*i])
      ret = max(ret,1+solve(k*i));
  }
  return dp[k] = ret;
}

int main(void){
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    int x;
    scanf("%d",&x);
    f[x]++;
  }

  printf("%d\n",solve(1)+f[1]);
}