U = 3 * 10 ** 5 div = [[0] for _ in range(U + 1)] for i in range(1, U + 1): v = i * 2 while v <= U: div[v].append(i) v += i memo = [0] * (U + 1) n = int(input()) ans = 0 for a in map(int, input().split()): v = max(memo[i] for i in div[a]) + 1 if v > ans: ans = v memo[a] = v print(ans)