#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
const long long pi=998244353;
int m,k,l,sum;
int w[500008],a[500002];
void swap(int *a, int *b)
{
int m;
m =*a;
*a =*b;
*b = m;
}
int perm(int list[], int k, int m)
{
int i;
long long n=0;
if(k > m)
{
n++;
return n%pi;
}
else
{
for(i = k; i <= m; i++)
{
swap(&list[k], &list[i]);
perm(list, k + 1, m);
swap(&list[k], &list[i]);
}
}
}
int main()
{
freopen("asm_formation.in","r",stdin);
freopen("asm_formation.out","w",stdout);
cin>>k;
for(int i=1;i<=k;i++)
{
cin>>a[i];
if(i!=1&&i!=k&&a[i]>1)a[i]-=1;
}
int tot =0;
for(int i=1;i<=k;i++)
while(a[i]>0){w[tot]=i;tot++;a[i]--;}
sum=perm(a,0,tot-1);
cout<<sum<<endl;
return 0;
}