import math n = int(input()) a = list(map(int, input().split())) m = 10 ** 5 dp = [0 for _ in range(n)] idx = [None for _ in range(m + 1)] for i in range(n): for x in range(1, int(math.sqrt(a[i])) + 1): if a[i] % x == 0: if not idx[x] is None: dp[i] = max(dp[i], dp[idx[x]] + 1) if x != a[i] // x and not idx[a[i] // x] is None: dp[i] = max(dp[i], dp[idx[a[i] // x]] + 1) dp[i] = max(dp[i], 1) idx[a[i]] = i print(max(dp))