def d(K): if K == 1: return [0] res = [] i = 1 while i * i <= K: if K % i == 0: if i != K: res.append(i) j = K // i if i != j and j != K: res.append(j) i += 1 return res Z = 3 * 10**5 L = [0] * (Z+1) N = int(input()) A = list(map(int, input().split())) R = {} for a in A: if not a in R: R[a] = d(a) for a in A: M = max(L[r] for r in R[a]) L[a] = M + 1 ans = max(L) print(ans)