<>; @a=glob<>; map{ $x=$a[$i++]<$_|0; $y=$x^1; $\+=push@$x,$i-1; pop@$y while@$y&&$a[$$y[-1]]<$_^$y; if(@$y){ $j=$$y[-1]; $a=-1;$b=@$x; ${$$x[$c]<$j?a:b}=$c=$a+$b>>1while$a+1<$b; $\-=$b; } }@a[1..$#a]; print