def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) Amax = 3*10**5 div = [[] for _ in range(Amax+1)] for i in range(1, Amax+1): for j in range(2, Amax // i + 1): div[i*j].append(i) dp = [0] * (Amax+1) for a in A: if a == 1: dp[a] = 1 continue for d in div[a]: dp[a] = max(dp[a], dp[d] + 1) print(max(dp)) if __name__ == '__main__': main()