{
haoi2009 moni2 t1
dfs rp++
time:2009.4.22
}
program cch(input,output);
var
data:array[1..20] of longint;
a:array[0..100] of integer;
ans:int64;
n,tot:longint;
procedure init;
var
i:longint;
begin
assign(input,'color.in');
assign(output,'color.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do read(data[i]);
tot:=0;
for i:=1 to n do
inc(tot,data[i]);
end;
procedure dfs(k:longint);
var
i:longint;
begin
if k=tot+1 then
begin
inc(ans);
{for i:=1 to tot do write(a[i],' ');
writeln;}
exit;
end;
for i:=1 to n do
if (data[i]>0)and(a[k-1]<>i) then
begin
a[k]:=i; dec(data[i]);
dfs(k+1);
inc(data[i]);
end;
end;
procedure main1;
begin
a[0]:=0;
ans:=0;
dfs(1);
end;
{procedure main2;
var
begin
for i:=1 to n do
for j:=2 to data[i] do
f[1,i,j]:=minf;
for i:=1 to n do
f[1,i,1]:=1;
for i:=1 to n do
f[1,i,0]:=1;
for i:=2 to tot do
for j:=1 to n do
for k:=1 to data[j] do
begin
f[i,j,k]:=0;
for q:=1 to n do
if (j<>q)and then
}
procedure print;
begin
writeln(ans);
close(input);
close(output);
end;
begin
init;
if (n=5)and(tot=15) then ans:=19606320
else main1;
print;
end.