program kjdiwdl;
var i,j,k,m,n:longint;sum:int64;
a,b,c,l,r:array[0..100000]of longint;
function lowbit(x:longint):longint;
begin
exit(x and(-x));
end;
function get(x:longint):longint;
var sum1:longint;
begin
sum1:=0;
while x>0 do
begin
sum1:=sum1+c[x];
x:=x-lowbit(x);
end;
exit(sum1);
end;
procedure add(x,y:longint);
begin
while x<=35000 do
begin
c[x]:=c[x]+y;
x:=x+lowbit(x);
end;
end;
begin
assign(input,'queueb.in');reset(input);
assign(output,'queueb.out');rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(a[i]);
a[i]:=a[i]+1;
add(a[i],1);
l[i]:=get(a[i]-1);
end;
fillchar(c,sizeof(c),0);
for i:=n downto 1 do
begin
add(a[i],1);
r[i]:=get(a[i]-1);
end;
for i:=1 to n do
sum:=sum+l[i]*r[i];
writeln(sum);
close(input);close(output);
end.