import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,*A = map(int,read().split()) INF = 100 U = 3 * 10 ** 5 + 10 length = [0] * U div = [[] for _ in range(U)] for n in range(1,U//2): for m in range(n+n,U,n): div[m].append(n) for x in A: length[x] = max((length[d] for d in div[x]), default=0) + 1 answer = max(length) print(answer)