from collections import defaultdict STOP = 3*10**5 + 1 DIVISORS = [[] for i in range(STOP)] for i in range(1, STOP): for j in range(2*i, STOP, i): DIVISORS[j].append(i) N = int(input()) A = list(map(int, input().split())) dp = defaultdict(int) for a in A: dp[a] = max(dp[a], 1) for d in DIVISORS[a]: dp[a] = max(dp[a], dp[d] + 1) K = max(dp.values()) print(K)