program xmz;
var
a,b,c,k,n:integer;
f1,f2:text;
x:array[1..15]of integer;
y:array[0..45]of integer;
s:longint;
procedure dfs(i:integer);
var
ii:integer;
begin
for ii:=1 to k do
if (x[ii]>0)and(ii<>y[i-1]) then
begin
y[i]:=ii; x[ii]:=x[ii]-1;
if i<n then dfs(i+1)
else begin s:=s+1;end;
x[ii]:=x[ii]+1;
end;
end;
begin
assign(f1,'color.in');assign(f2,'color.out');
reset(f1);rewrite(f2);
read(f1,k);
for a:=1 to k do
begin read(f1,x[a]);n:=n+x[a];end;
dfs(1);
writeln(f2,s);
close(f1);close(f2);
end.