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