N=int(input()) A=list(map(int,input().split())) DP=[set() for i in range(18)] DP[0]={1} for a in (A): if a==1: DP[1].add(1) for i in range(17,-1,-1): for s in DP[i]: if a>s and a%s==0: DP[i+1].add(a) for i in range(17,-1,-1): if DP[i]!=set(): print(i) break