import sys input = sys.stdin.buffer.readline N = int(input()) A = tuple(map(int, input().split())) MAX = 3 * 10 ** 5 table = [[] for _ in range(MAX + 1)] for i, a in enumerate(A): table[a].append(i) dp = [0] * N dp[0] = 1 for i, a in enumerate(A): for b in range(a * 2, MAX + 1, a): for j in table[b]: if i < j: dp[j] = max(dp[j], dp[i] + 1) print(max(dp))