/EZSORT - Sắp xếp là chuyện nhỏ!

<Problem>

http://ntucoder.net/Problem/Details/5622
              Uses Crt;
        Type arr=array[1..300000] of longint;
        Var n,i,j,kq,vt,n1:longint; a:arr;
        Begin
            readln(n); n1:=n;
            for i:=1 to n do
            begin
                read(a[i]);
                if a[i]=n then vt:=i;
            end;
            for i:=vt downto 1 do
              if a[i]=n then begin inc(kq); dec(n); end;
            writeln(n1-kq);
            readln;
        End.