var a:array[1..4000000] of boolean;
x:array[1..4000000] of longint;
y:array[1..4000000] of longint;
num:array[1..4000000] of longint;
last:array[1..4000000] of longint;
n,i,u,j,s:longint;total:qword;
function dizheng:boolean;
var i,j:longint;
begin
for i:=1 to n-1 do
for j:=i to n do
if last[i]>last[j] then exit(false);
exit(true);
end;
procedure print;
var i,a,b:longint;r,t,w:string;v:boolean;
begin
fillchar(last,sizeof(last),0);
v:=true;
for i:=1 to n do
for j:=s downto 1 do
if x[j]=i then begin last[i]:=j;break;end;
if dizheng then total:=total+1;
end;
procedure try(i:longint);
var j:longint;
begin
for j:=1 to s do
if a[j]=true then begin
x[i]:=y[j];
a[j]:=false;
if i<s
then try(i+1)
else print;
a[j]:=true;
end;
end;
procedure same;
begin
for i:=1 to n do
if num[1]<>1 then exit;
writeln(1);
halt;
end;
begin
assign(input,'asm_formation.in');
reset(input);
assign(output,'asm_formation.out');
rewrite(output);
total:=0;readln(n);
for i:=1 to n do begin
read(num[i]); s:=s+num[i]; end;
u:=1;
same;
{ for i:=1 to n do
begin
for j:=1 to num[i] do
y[u]:=i;
u:=u+1;
end; }
for i:=1 to n do
for j:=1 to num[i] do
begin
y[u]:=i;
u:=u+1;
end;
for i:=1 to s do
a[i]:=true;
try(1);
total:=total div 4;
total:=total mod 998244353;
writeln(total);
close(input);
close(output);
end.