N = int(input()) A = list(map(int, input().split())) 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 D = {} for a in A: if not a in D: D[a] = make_divisors(a) ans = 0 X = [0] * (3 * 10**5 + 1) for a in A: M = 0 for d in D[a]: if d == a: continue M = max(M, X[d]) M += 1 ans = max(ans, M) X[a] = M print(ans)