from collections import * N = int(input()) A = list(map(int, input().split())) M = 3 * 10 **5 + 5 D = [[] for i in range(M)] for i in range(1, M): for j in range(2 * i ,M, i): D[j].append(i) dic = defaultdict(int) for a in A: val = 0 for d in D[a]: val = max(val, dic[d]) dic[a] = val + 1 ans = 0 for k, v in dic.items(): ans = max(ans, v) print(ans)