import sys readline = sys.stdin.readline ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) def solve(): n = ni() a = nl() s = set(a) m = max(a) + 5 g = [[1] for _ in range(m)] for i in range(2, m): if i in s: for j in range(i*2, m, i): g[j].append(i) c = [-1]*m c[1] = 0 for x in a: if x == 1: c[x] = 1 else: c[x] = max([c[y] for y in g[x]]) + 1 print(max(c)) return solve()