n = int(input()) A = list(map(int, input().split())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors dp = [0]*(max(A)+1) for a in A: if a == 1: dp[1] = 1 continue d = make_divisors(a) for i in d: if i == a: continue dp[a] = max(dp[i]+1, dp[a]) #print(dp) print(max(dp))