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