from collections import * class Divisor(): def __init__(self, N): self.L = list(range(N + 1)) for i in range(2, N + 1): if i != self.L[i]: continue for j in range(2 * i, N + 1, i): self.L[j] = i def factorize(self, n): if n <= 1: return [] D = [] while n != 1: cnt = 0 now = self.L[n] while n % now == 0: cnt += 1 n //= now D.append((now, cnt)) return D def div(self, n): A = self.factorize(n) now = [1] for k, v in A: M = len(now) for i in range(M): x = now[i] for _ in range(v): x *= k now.append(x) return now N = int(input()) A = list(map(int, input().split())) D = Divisor(10**5+5) pre = defaultdict(lambda : -10) pre[1] = 0 for a in A: dp = defaultdict(lambda : -10) for d in D.div(a): dp[a] = max(dp[a], pre[d] + 1) for k, v in pre.items(): dp[k] = max(dp[k], v) dp, pre = pre, dp ans = 0 for k, v in pre.items(): ans = max(ans, v) print(ans)