N = int(input()) A = list(map(int, input().split())) Z = 3 * 10**5 Z = 10 R = [[] for _ in range(Z+1)] for i in range(1, Z+1): for j in range(i+i, Z+1, i): R[j].append(i) R[1].append(0) L = [0] * (Z+1) for a in A: M = max(L[r] for r in R[a]) L[a] = M + 1 ans = max(L) print(ans)