use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf).ok(); let mut buf = String::new(); io::stdin().read_line(&mut buf).ok(); let a: Vec = buf .trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect(); let mut result = 0; for v in a.windows(3) { result += match v { [a, b, c] if a > c => match (a, b, c) { (a, b, c) if b > a || b < c => 1, _ => 0, }, [a, b, c] if a < c => match (a, b, c) { (a, b, c) if b > c || b < a => 1, _ => 0, }, _ => 0, }; } println!("{}", result); }