n=int(input()) a=list(map(int,input().split())) x=[0]*(5*10**5) for i in a: c=1 if i>1: c=x[1]+1 for j in range(2,int(i**0.5)+1): c=max(c,x[j]+1,x[i//j]+1) x[i]=max(x[i],c) print(max(x))