from collections import defaultdict def divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] N=int(input()) x=list(map(int,input().split())) x.sort() rui=defaultdict(int) for i in range(N): now=divisors(x[i]) rui[x[i]]=1 for next in now: if x[i]==next:continue rui[x[i]]=max(rui[x[i]],rui[next]+1) print(max(rui.values()))