# 先頭からdp的辞書でやるか # 倍数約数で行ったり来たりするので間に合わない気がする N = int(input()) A = list(map(int, input().split())) from collections import defaultdict A_position = defaultdict(list) for i in range(N): A_position[A[i]].append(i) #print(A_position) div = defaultdict(list) maxA = max(A) for i in range(N): for q in range(A[i], maxA+1, A[i]): for r in A_position[q]: if r > i: div[r].append(i) #print(div) dp = [0]*(N) dp[0] = 1 mx_dic = {} for i in range(N): num = A[i] mx = 1 for j in div[i]: mx = max(mx, dp[j]+1) dp[i] = mx #print(dp) ans = max(dp) print(ans)