const maxn=50001; maxa=40000;
var
l,r,ans:int64; a:array[0..maxn] of longint;
sum_l,sum_r:array[0..maxa] of longint;
n,i:longint;
function lowbit(k:longint):longint;
begin exit(k and (-k)); end;
function getsum_left(k:longint):longint;
var t:longint;
begin
t:=0;
while k>0 do
begin
t:=t+sum_l[k];
k:=k-lowbit(k);
end;
getsum_left:=t;
end;
function getsum_right(k:longint):longint;
var t:longint;
begin
t:=0;
while k>0 do
begin
t:=t+sum_r[k];
k:=k-lowbit(k);
end;
exit(t);
end;
procedure insert_right(k:longint);
begin
while k<=maxa do
begin
inc(sum_r[k]);
k:=k+lowbit(k);
end;
end;
procedure delete_right(k:longint);
begin
while k<=maxa do
begin
dec(sum_r[k]);
k:=k+lowbit(k);
end;
end;
procedure insert_left(k:longint);
begin
while k<=maxa do
begin
inc(sum_l[k]);
k:=k+lowbit(k);
end;
end;
begin
assign(input,'queueb.in'); reset(input);
assign(output,'queueb.out'); rewrite(output);
readln(n);
for i:=1 to n do
begin
read(a[i]);
a[i]:=a[i]+1;
insert_right(a[i]);
end;
for i:=1 to n do
begin
delete_right(a[i]);
l:=getsum_left(a[i]-1);
r:=getsum_right(a[i]-1);
ans:=ans+l*r;
insert_left(a[i]);
end;
writeln(ans);
close(input); close(output);
end.