from collections import deque N=int(input()) A=list(map(int,input().split())) G=[[] for _ in range(N)] num=[0]*N for i in range(N): for j in range(i+1,N): if A[j]>A[i] and A[j]%A[i]==0: G[i].append(j) num[j]+=1 elif A[i]>A[j] and A[i]%A[j]==0: G[j].append(i) num[i]+=1 D=deque() for i in range(N): if not num[i]: D.append(i) DP=[1]*N while D: v=D.popleft() for nv in G[v]: DP[nv]=max(DP[nv],DP[v]+1) num[nv]-=1 if not num[nv]: D.append(nv) print(max(DP))