import sys def main(): input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:N+1])) max_num = 300000 spf = list(range(max_num + 1)) for i in range(2, int(max_num**0.5) + 1): if spf[i] == i: for j in range(i*i, max_num + 1, i): if spf[j] == j: spf[j] = i memo_factors = {} def get_factors(x): if x in memo_factors: return memo_factors[x] original_x = x factors = {} temp = x while temp > 1: p = spf[temp] while temp % p == 0: factors[p] = factors.get(p, 0) + 1 temp //= p memo_factors[original_x] = factors return factors max_len = 0 dp = [0] * (max_num + 1) for x in A: factors = get_factors(x) max_prev = 0 divisors = [1] for p, exp in factors.items(): new_divisors = [] for d in divisors: current = d new_d = current for _ in range(exp + 1): new_divisors.append(new_d) if new_d < x and dp[new_d] > max_prev: max_prev = dp[new_d] new_d *= p divisors = new_divisors current_length = max_prev + 1 if current_length > dp[x]: dp[x] = current_length if dp[x] > max_len: max_len = dp[x] print(max_len) if __name__ == "__main__": main()