N = int(input()) A = list(map(int,input().split())) C = 10 ** 5 + 5 div = [[1] for _ in range(C)] for i in range(2,C): for j in range(i + i,C,i): div[j].append(i) d = dict() for a in A: if a not in d: d[a] = 1 for u in div[a]: if u in d: d[a] = max(d[a],d[u] + 1) ans = 0 for v in d.values(): if v > ans: ans = v print(ans) #print(d)