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 IND = [-1] * (MAX+1) for i in range(N): ai = A[i] last = IND[ai] if last != -1 and dp[last] >= dp[i]: pass IND[ai] = 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))