divisors=[[] for i in range(3*10**5+1)] for i in range(1,3*10**5+1): for j in range(1,3*10**5//i+1): divisors[i*j].append(i) import sys input=sys.stdin.buffer.readline N=int(input()) A=list(map(int,input().split())) data=[0]*(max(A)+1) for i in range(N): test=1 for D in divisors[A[i]]: if D!=A[i]: test=max(test,data[D]+1) data[A[i]]=max(data[A[i]],test) print(max(data))