{ JC05: Chiu Jiawei, Hwa Chong JC }
{ Comment: Elegant, short and crisp.  Note the clever 
           use of an additional array element, h[n+1].  
           Such is a simple but useful little technique. }
           

program p1_route;

type
    STATE = (Nothing, Level, Up, Down);

var
    fin, fout: text;
    n: integer;
    h: array[1..30100] of integer;
    l, u, d: integer;
    i: integer;
    last, s: STATE;

begin

    assign(fin, 'route.in');
    reset(fin);

    l:= 0; u:= 0; d:= 0;

    readln(fin, n);
    for i:= 1 to n do readln(fin, h[i]);

    h[n+1]:= h[1];
    last:= Nothing;
    for i:= 2 to n+1 do
    begin
        if (h[i]>h[i-1]) then
            s:= Up
        else if (h[i]<h[i-1]) then
            s:= Down
        else
            s:= Level;

        if (s<>last) then
        begin
            case s of
                Level: inc(l);
                Up: inc(u);
                Down: inc(d);
            end;
        end;
        last:= s;
    end;

    assign(fout, 'route.out');
    rewrite(fout);
    writeln(fout, l, ' ', u, ' ', d);
    close(fout);

end.


