from functools import lru_cache @lru_cache(maxsize=100000) def make_divisors(n): divisors = [] #必要に応じてsetにしても良いかも i = 1 while i ** 2 <= n: if n % i == 0: divisors.append(i) if i ** 2 != n: divisors.append(n//i) i += 1 #divisors.sort() return divisors N = int(input()) A = list(map(int, input().split())) maxa = max(A) C = [set() for _ in range(maxa + 1)] E = [0] * (maxa + 1) for a in reversed(A): tmp = 0 if C[a]: for x in C[a]: tmp = max(tmp, E[x]) E[a] = max(E[a], tmp + 1) D = make_divisors(a) for d in D: C[d].add(a) print(max(E))