#d1102. 最长因子链

最长因子链

Longest Factor Chain

Problem Description

Given an array a1,a2,…,ana_1, a_2, \dots, a_n of length nn, find the length of the longest factor chain. That is, find the largest mm and indices p1,p2,…,pmp_1, p_2, \dots, p_m such that the pip_i are pairwise distinct and ap1a_{p_1} is a factor of ap2a_{p_2}, ap2a_{p_2} is a factor of ap3a_{p_3}, …\dots

Note that a number is a factor of itself, and the numbers do not need to appear in order.

Input Format

The first line contains an integer nn.

The next line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n.

Output Format

One integer — the answer.

Sample Input

6
3 7 4 2 6 8

Sample Output

3

Constraints

All data satisfy 1≤n≤10001 \le n \le 1000 and 1≤ai≤1091 \le a_i \le 10^9.