n = int(input()) A = list(map(int, input().split())) ma = max(A) dp = [0] * (ma + 1) for a in A: if a == 1: ma = 1 else: if dp[1] + 1 > dp[a]: ma = dp[1] + 1 else: ma = dp[a] for i in range(2, int(a ** 0.5 + 1)): if a % i == 0: if dp[i] + 1 > ma: ma = dp[i] + 1 elif dp[a // i] + 1 > ma: ma = dp[a // i] + 1 dp[a] = ma print(max(dp))