from collections import defaultdict N = int(input()) S = list(map(int, input().split())) S.sort() s = set(S) d = defaultdict(int) if N == 1: print(1) exit() for ss in S: d[ss] = 1 def yaku(X): res = 1 for i in range(1, X+1): if i*i > X: break if X%i == 0: if i in s: res = max(res, d[i]+1) if i*i != X and X//i in s and X//i != X: res = max(res, d[X//i]+1) d[X] = res return res ans = 0 for i in range(1, N): ans = max(ans, yaku(S[i])) print(ans)