显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int SIZEN=100010,SIZEK=500010;
typedef long long LL;
const LL MOD=998244353;
int N;
LL sum[SIZEN];
LL fact[SIZEK],inv[SIZEK],inv_fact[SIZEK];
void read()
{
scanf("%d",&N);
int S=0;
for(int i=1;i<=N;i++)
{
scanf("%d",&sum[i]);
S+=sum[i];
}
inv_fact[0]=inv[1]=inv_fact[1]=fact[0]=fact[1]=1;
for(int i=2;i<=S;i++)
{
fact[i]=(fact[i-1]*i)%MOD;
inv[i]=(-(MOD/i)*inv[MOD%i])%MOD;
inv[i]=(inv[i]+MOD)%MOD;
inv_fact[i]=(inv_fact[i-1]*inv[i])%MOD;
}
}
LL C(LL a,LL b)
{
return fact[b]*inv_fact[a]%MOD*inv_fact[b-a]%MOD;
}
void work()
{
LL ans=1;
int S;
S=sum[1];
for(int i=2;i<=N;i++)
{
ans*=C(S,S+sum[i]-1);
ans%=MOD;
S+=sum[i];
}
printf("%lld",ans);
}
int main()
{
freopen("asm_formation.in","r",stdin);
freopen("asm_formation.out","w",stdout);
read();
work();
return 0;
}