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