def get_divisor(n): divisor = set() divisor.add(1) for i in range(1, n//2+1): if n % i == 0: divisor.add(i) divisor.add(n//i) return list(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)]) print(max(length))