# 約数のリストを得る 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())) D = {} for a in A: if a in D: continue D[a] = make_divisors(a) dp = [0] * (max(A) + 1) for a in A: if a == 1: dp[1] = 1 for x in D[a]: if x == a: continue dp[a] = max(dp[a], dp[x] + 1) print(max(dp))