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) { let &max = v.iter().max().unwrap(); let &min = v.iter().min().unwrap(); if v[1] == max || v[1] == min { result += 1; } } println!("{}", result); }