package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { var n, count int nums := make([]int, 0, 100) fmt.Scanln(&n) scanner := bufio.NewScanner(os.Stdin) scanner.Scan() for _, v := range strings.Split(scanner.Text(), " ") { i, _ := strconv.Atoi(v) nums = append(nums, i) } for i := 0; i < n-2; i++ { col := nums[i : i+3] if (col[1] < col[0] && col[0] < col[2]) || (col[2] < col[0] && col[0] < col[1]) { count++ continue } if (col[0] < col[2] && col[2] < col[1]) || (col[1] < col[2] && col[2] < col[0]) { count++ } } fmt.Println(count) }