Z = 3 * 10**5 Z = 10 D = [[0] for _ in range(Z+1)] for i in range(1, Z+1): for j in range(i+i, Z+1, i): D[j].append(i) N = int(input()) A = list(map(int, input().split())) inf = float("inf") dp = [-inf] * (Z+1) dp[0] = 0 for a in A: for d in D[a]: dp[a] = max(dp[a], dp[d] + 1) print(max(dp))