n = int(input()) arr = map(int,raw_input().split()) arr.sort() def divisor(n): ret = [] i = 1 while i ** 2 <= n : if n % i == 0 : ret.append(i) if i ** 2 != n: ret.append(n/i) i += 1 ret.sort() ret.reverse() return ret dp = [0]*(10**6+1) for i in arr: for k in divisor(i): dp[i] = max(dp[i], dp[k] + 1) print max(dp)