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) dp[0] = 0 for i := 1; i <= n; i++ { next := make([]int, int(1e5)+1) //make(map[int]int) for k := range dp { next[k] = dp[k] } d := divide(a[i-1]) d = append([]int{0}, d...) for _, v := range d { next[a[i-1]] = Max(next[a[i-1]], dp[v]+1) } dp = next } 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 }