def make_divisors(n): divisors = [] i = 1 while i * i <= n: if n % i == 0: divisors.append(i) j = n // i if i != j: divisors.append(j) i += 1 return divisors N = int(input()) A = list(map(int, input().split())) Z = 3 * 10**5 Z = 9 X = [0] * (Z+1) for a in A: if a == 1: X[1] = 1 else: for d in make_divisors(a): if d == a: continue X[a] = max(X[a], X[d] + 1) print(max(X))