N = int(input()) A = sorted(list(map(int,input().split()))) D = [-1]*(10**6+1) for i in range(N): D[A[i]] = i G = {i:[] for i in range(N)} for i in range(N): a = A[i] for j in range(1,a): if j*j>a:break if a%j==0: if D[j]>=0: G[i].append(D[j]) if D[a//j]>=0 and a//j!=a: G[i].append(D[a//j]) dp = [1]*N for i in range(N): for j in G[i]: dp[i] = max(dp[i],dp[j]+1) print(max(dp))