c=[-1]*m=1000001;gets;gets.split.map{|i|c[i=i.to_i]=1;i}.sort{|i|(i+i).step(m-1,i){|j|c[j]=[c[j],c[i]+1].max if c[j]>=0}};p c.max