program cogs990;
var
a,b:array[0..600000]of int64;
i,n:longint;
sum:int64;
procedure init;
begin
assign(input,'sop.in');reset(input);
assign(output,'sop.out');rewrite(output);
end;
procedure sort(l,r:longint);
var
i,t,p,q,mid:longint;
begin
if l=r then exit;
mid:=(l+r)shr 1;
sort(l,mid);sort(mid+1,r);
p:=l;q:=mid+1;
t:=l-1;
repeat
inc(t);
if a[p]>a[q] then
begin
b[t]:=a[q];
inc(q);inc(sum,mid+1-p);
end else begin
b[t]:=a[p];
inc(p);
end;
until(p>mid)or(q>r);
if p<=mid then
begin
for i:=p to mid do
begin
inc(t);
b[t]:=a[i];
end;
end else
begin
for i:=q to r do
begin
inc(t);
b[t]:=a[i];
end;
end;
for i:=l to r do a[i]:=b[i];
end;
procedure main;
begin
readln(n);
for i:=1 to n do read(a[i]);
sort(1,n);
writeln(sum);
end;
begin
init;
main;
end.//complete by chouyi 20141023