N = int(input()) A = list(map(int,input().split())) lis = [ [] for i in range(3*(10**5)+1) ] maxlen = [0] * N for loop in range(N): na = A[loop] for i in range(int(na**0.5)+1): i += 1 if na % i == 0: for j in lis[i]: maxlen[loop] = max(maxlen[loop] , maxlen[j] + 1) if na // i != na: for j in lis[na//i]: maxlen[loop] = max(maxlen[loop] , maxlen[j] + 1) lis[na].append(loop) #print (maxlen) print (max(maxlen)+1)