var n,i,ans:longint;
a,r:array[0..1000000]of longint;
procedure msort(s,t:longint);
var i,j,k,m:longint;
begin
if s=t then exit;
m:=(s+t)div 2;
msort(s,m);
msort(m+1,t);
i:=s; j:=m+1; k:=s;
while (i<=m)and(j<=t) do begin
if a[i]<=a[j] then begin r[k]:=a[i]; inc(i); inc(k); end
else begin r[k]:=a[j]; inc(j); inc(k); inc(ans,m-i+1);end;
end;
while i<=m do begin r[k]:=a[i]; inc(k); inc(i);end;
while j<=t do begin r[k]:=a[j]; inc(k); inc(j);end;
for i:=s to t do a[i]:=r[i];
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
msort(1,n);
//for i:=1 to n do write(a[i],' ');
writeln(ans);
close(input);
close(output);
end.