import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) dp = [0]*(10**5+10) for Ai in A: if Ai==1: dp[Ai] += 1 else: for d in range(1, int(Ai**0.5)+1): if Ai%d==0: dp[Ai] = max(dp[Ai], dp[Ai//d]+1) dp[Ai] = max(dp[Ai], dp[d]+1) print(max(dp))