program t2(input,output);
var
ans:array[1..10000]of longint;
data:array[1..10000]of real;
n,i,j:integer;
begin
fillchar(ans,sizeof(ans),0);
fillchar(data,sizeof(data),0);
assign(input,'sortt.in');
reset(input);
readln(input,n);
for i:= 1 to n do
read(input,data[i]);
close(input);
for i:= n-1 downto 1 do
begin
for j:=n downto i+1 do
begin
if data[j]<data[i] then inc(ans[i],ans[j]+1);
end;
end;
for i:= 2 to n do
begin
inc(ans[1],ans[i]);
end;
assign(output,'sortt.out');
rewrite(output);
write(output,ans[1]);
close(output);
end.