package main import ( "bufio" "fmt" "os" "sort" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var out = bufio.NewWriter(os.Stdout) func main() { //bufサイズ以上の文字列入力が必要な場合は拡張すること buf := make([]byte, 9*1024*1024) sc.Buffer(buf, bufio.MaxScanTokenSize) sc.Split(bufio.ScanWords) n := nextInt() a := nextIntSlice(n) ans := solve(n, a) PrintInt(ans) } func divide(x int) []int { m := make(map[int]struct{}) for i := 1; i*i <= x; i++ { if x%i == 0 { m[i] = struct{}{} m[x/i] = struct{}{} } } var res []int for k := range m { res = append(res, k) } sort.Ints(res) return res } func solve(n int, a []int) int { dp := make([]int, int(1e5)+1) //make(map[int]int) for i := 1; i <= n; i++ { d := divide(a[i-1]) mx := 1 for _, v := range d { mx = Max(mx, dp[v]+1) } dp[a[i-1]] = mx } var ans int for _, v := range dp { ans = Max(ans, v) } return ans } func nextInt() int { sc.Scan() i, _ := strconv.Atoi(sc.Text()) return int(i) } func nextIntSlice(n int) []int { s := make([]int, n) for i := range s { s[i] = nextInt() } return s } func PrintInt(x int) { defer out.Flush() fmt.Fprintln(out, x) } func Min(x, y int) int { if x < y { return x } return y } func Max(x, y int) int { if x < y { return y } return x }