n=int(input()) a=list(map(int,input().split())) L=max(a) o=[0]*(L+1) for v in a: o[v]=1 q=[0]*(L+1) for i in range(1,L+1): j=1 while j*j<=i: if i%j==0: q[i]=max(q[i],q[i//j],q[i//(i//j)]) j+=1 q[i]+=o[i] print(max(q[i] for i in range(L+1) if o[i]))