var
i,j,k,n,ans:longint;
a:array[1..200] of longint;
f,p:array[1..20000,0..2000] of longint;
begin
assign(input,'three.in');
reset(input);
assign(output,'three.out');
rewrite(output);
read(n);
for i:= 1 to n do
read(a[i]);
for i:= 1to n do
for j:= i+1to n do
if a[i]<a[j] then
begin
inc(f[i,0]);
f[i,f[i,0]]:=a[j];
p[i,f[i,0]]:=j;
end;
for i:= 1to n do
for j:= 1to f[i,0] do
begin
for k:=1 to f[p[i,j],0] do
inc(ans);
end;
writeln(ans);
close(input);
close(output);
end.