def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors[:-1] n = int(input()) a = [int(i) for i in input().split()] dp = [0]*(max(a)+1) for i in range(n): div = make_divisors(a[i]) tmp = 0 for j in range(len(div)): #print(div[j],j) tmp = max(tmp,dp[div[j]]) dp[a[i]] = max(dp[a[i]],tmp+1) print(max(dp))