program fall;
var ans,n,i,j:longint;
a,f:array [1..33333] of longint;
begin
assign(input,'three.in'); reset(input);
assign(output,'three.out'); rewrite(output);
readln(n); fillchar(f,sizeof(f),0); ans:=0;
for i:=1 to n do readln(a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[j]>a[i] then inc(f[i]);
for i:=1 to n-2 do
for j:=i+1 to n-1 do
if a[j]>a[i] then inc(ans,f[j]);
writeln(ans);
close(input);
close(output);
end.