def get_divisor(n): divisor = [] for i in range(1, n//2+1): if n % i == 0: divisor.append(i) divisor.append(n//i) return divisor n = int(input()) x = list(map(int, input().split())) x.sort() length = [0 for i in range(max(x)+1)] for e in x: length[e] = max(length[e], *[length[d]+1 for d in get_divisor(e)]) # length[e] = max([length[d]+1 for d in get_divisor(e)]) print(max(length))