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() m = max(a) + 5 g = [list() for _ in range(m)] for i in range(1, m): 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()