import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() a = li() dp = [-inf] * (n + 1) dp[0] = 1 maxi = [0] * (max(a) + 1) div = [set() for _ in range(max(a) + 1)] for idx, v in enumerate(a): v2 = v if not div[v]: for i in range(1, v2 + 1): if i * i > v2: continue if v2 % i == 0: div[v].add(i) div[v].add(v2 // i) for v2 in div[v]: dp[idx] = max(dp[idx], maxi[v2] + 1) maxi[v] = dp[idx] print(max(dp))