from sys import stdin input=lambda :stdin.readline()[:-1] class SOE: def __init__(self,m): self.sieve=[-1]*(m+1) self.prime=[] for i in range(2,m+1): if self.sieve[i]==-1: self.prime.append(i) self.sieve[i]=i j=2*i while j<=m: self.sieve[j]=i j+=i def primes(self): # get primes return self.prime def fact(self,n): # prime factorization d=[] while n!=1: p=self.sieve[n] e=0 while n%p==0: e+=1 n//=p d.append((p,e)) return d def div(self,n): # get divisors c=[1] while n!=1: p=self.sieve[n] cnt=1 n//=p while self.sieve[n]==p: cnt+=1 n//=p s=c.copy() for i in s: for j in range(1,cnt+1): c.append(i*(p**j)) return c soe=SOE(10**5+10) n=int(input()) a=list(map(int,input().split())) dp=[0]*(10**5+10) for i in a: mx=0 for j in soe.div(i): mx=max(mx,dp[j]) dp[i]=mx+1 print(max(dp))