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(); println!( "{}", a.windows(3) .filter(|a| (a[0] != a[1] && a[1] != a[2] && a[2] != a[0]) && (a[1] > if a[0] > a[2] { a[0] } else { a[2] } || a[1] < if a[0] > a[2] { a[2] } else { a[0] })).count() ); }