def makediv(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()) a = list(map(int,input().split())) v = [0] * 100002 for i in range(n): tmp = 0 for j in makediv(a[i]): tmp = max(tmp, v[j]) v[a[i]] = max(v[a[i]], tmp + 1) print(max(v))