# 約数のリストを得る 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 N = int(input()) A = list(map(int, input().split())) dp = [0] * (max(A)+1) for a in A: if a == 1: dp[a] = 1 else: Y = make_divisors(a) t = 0 for y in Y: if y == a: continue dp[a] = max(dp[a], dp[y] + 1) print(max(dp))