var n, i, j, d:integer;
    ans:array[1..1000000, 1..2]of integer;
    a:array of integer;
    c:longint;
begin
 
    read(n);
    setlength(a, n+1);
    for i:=1 to n do read(a[i]);

    c:=0;

    for i:=1 to n do 
        for j:=1 to n-1 do 
            if a[j]>a[j+1] then 
                begin 
                    inc(c); 
                    d:=a[j]; a[j]:=a[j+1]; a[j+1]:=d; 
                    ans[c, 1]:=j; ans[c, 2]:=j+1; 
                end;

    writeln(c);
    for i:=1 to c do writeln(ans[i, 1],' ',ans[i, 2]);

end.
