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