import math def main(): import sys input = sys.stdin.read().split() n = int(input[0]) A = list(map(int, input[1:n+1])) max_dp = dict() ans = 0 for x in A: divisors = set() if x != 1: sqrt_x = int(math.isqrt(x)) for i in range(1, sqrt_x + 1): if x % i == 0: divisors.add(i) if i != 1: other = x // i divisors.add(other) divisors.discard(x) # Ensure x is not in divisors # Now find the maximum dp among divisors current_max = 0 for d in divisors: if d in max_dp and max_dp[d] > current_max: current_max = max_dp[d] dp_x = current_max + 1 # Update max_dp for x if x in max_dp: if dp_x > max_dp[x]: max_dp[x] = dp_x else: max_dp[x] = dp_x # Update the answer if dp_x > ans: ans = dp_x print(ans) if __name__ == "__main__": main()