from collections import defaultdict from bisect import bisect_left N = int(input()) A = list(map(int,input().split())) MAX = max(A) memo = [[] for _ in range(MAX+1)] for i,a in enumerate(A): memo[a].append(i) Aset = set() dp = [1] * N for i in range(N): ai = A[i] if ai in Aset: continue Aset.add(ai) 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))