N = int(input()) A = list(map(int, input().split())) Z = 3 * 10**5 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) X = [0] * (Z+1) for a in A: if a == 1: X[1] = 1 else: for r in R[a]: X[a] = max(X[a], X[r] + 1) print(max(X))