import sys import math def get_divisors(x): if x == 1: return [] divisors = set() x_sqrt = math.isqrt(x) i = 1 while i <= x_sqrt: if x % i == 0: if i < x: divisors.add(i) j = x // i if j < x and j != i: divisors.add(j) i += 1 return divisors def main(): input = sys.stdin.read().split() n = int(input[0]) A = list(map(int, input[1:n+1])) dp = dict() max_val = 0 for x in A: divisors = get_divisors(x) current_max = 0 for y in divisors: if y in dp and dp[y] > current_max: current_max = dp[y] new_val = current_max + 1 if x in dp: if new_val > dp[x]: dp[x] = new_val else: dp[x] = new_val if dp[x] > max_val: max_val = dp[x] print(max_val) if __name__ == '__main__': main()