from collections import defaultdict from bisect import bisect_left N = int(input()) A = list(map(int,input().split())) MAX = max(A) newA = [] Aset = set() for a in A: if a in Aset: continue newA.append(a) Aset.add(a) N = len(newA) A = newA memo = [[] for _ in range(MAX+1)] for i,a in enumerate(A): memo[a].append(i) dp = [1] * N for i in range(N-1): ai = A[i] for m in range(2,(MAX//ai) + 1): if memo[ai * m] == []: continue index = bisect_left(memo[ai * m],i) if index == len(memo[ai * m]): continue nxi = memo[ai * m][index] dp[nxi] = max(dp[i] + 1,dp[nxi]) print(max(dp))