from bisect import bisect_left import sys input = sys.stdin.readline def main(): n = int(input()) X = list(map(int, input().split())) X.sort() Idxs = [[] for _ in range(10**6 + 1)] for i in range(n): Idxs[X[i]].append(i) L = [0 for _ in range(10**6 + 1)] for i in range(10**6 + 1): L[i] = len(Idxs[i]) DP = [[-1, -1] for _ in range(10**6 + 1)] for i in range(1, 10**6 + 1): if Idxs[i]: DP[i] = [1, Idxs[i][0]] ans = 1 for i in range(1, 10**6 + 1): if DP[i][0] != -1: for j in range(2 * i, 10**6 + 1, i): if Idxs[j]: idx = bisect_left(Idxs[j], DP[i][1]) if idx == L[j]: continue k = Idxs[j][idx] if DP[i][0] + 1 > DP[j][0]: DP[j] = [DP[i][0] + 1, k] elif DP[i][0] + 1 == DP[j][0]: if k < DP[j][1]: DP[j][1] = k ans = max(ans, DP[j][0]) print(ans) if __name__ == '__main__': main()