import sys def main(): input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:N+1])) max_A = 300000 # As per problem constraints # Precompute divisors for all x up to max_A divisors = [[] for _ in range(max_A + 1)] for d in range(1, max_A + 1): multiple = d * 2 while multiple <= max_A: divisors[multiple].append(d) multiple += d max_dp = dict() answer = 0 for x in A: current_max = 0 for d in divisors[x]: if d in max_dp and max_dp[d] > current_max: current_max = max_dp[d] dp = current_max + 1 if x in max_dp: if dp > max_dp[x]: max_dp[x] = dp else: max_dp[x] = dp if dp > answer: answer = dp print(answer) if __name__ == '__main__': main()