extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};
use std::fmt::{Display, Formatter, Error};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
#[derive(Copy, Clone)]
enum State {
    Down, Horizontal, Up
}
fn solve(heights: Vec<i32>) {
    let mut plateau= 0;
    let mut basin = 0;
    let mut hillside = 0;
    let mut peak = 0;
    let mut dent = 0;
    let mut stack = Vec::<State>::with_capacity(2);
    for i in 2 .. heights.len() {
        if heights[i - 1] < heights[i] {
            match stack.pop() {
                Some(State::Down) => dent += 1,
                Some(State::Horizontal) => match stack.pop() {
                    Some(State::Up) => hillside += 1,
                    Some(State::Down) => basin += 1,
                    None => {}
                    _ => unreachable!()
                },
                _ => {}
            }
            stack.push(State::Up);
        }else if heights[i - 1] > heights[i] {
            match stack.pop() {
                Some(State::Up) => peak += 1,
                Some(State::Horizontal) => match stack.pop() {
                    Some(State::Up) => plateau += 1,
                    Some(State::Down) => hillside += 1,
                    None => {}
                    _ => unreachable!()
                },
                _ => {}
            }
            stack.push(State::Down);
        }else {
            if let Some(&State::Horizontal) = stack.last() {} else {stack.push(State::Horizontal)}
        }
    }
    println!("{} {} {} {} {}", plateau, basin, hillside, peak, dent);
}
fn main(){
    solve(read_line!(' '; i32));
}


Measured memory_bytes: 5036