显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
#define mod 998244353
#define maxn 510000
using namespace std;
typedef unsigned long long ll;
ll num[maxn],sum[maxn],fac[maxn];
ll fast_pow(ll a,ll k ){
ll ans=1;
while(k){
if(k&1){
ans*=a;
ans%=mod;
}
a*=a;
a%=mod;
k>>=1;
}
return ans;
}
int main(){
freopen("asm_formation.in","r",stdin);
freopen("asm_formation.out","w",stdout);
ios::sync_with_stdio(0);
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>num[i];
sum[i]+=num[i];
sum[i]+=sum[i-1];
}
fac[1]=1;
fac[0]=1;
for(int i=2;i<maxn;i++){
fac[i]=1;
fac[i]*=i;
fac[i]*=fac[i-1];
fac[i]%=mod;
}
ll ans=1;
for(int i=1;i<=n;i++){
if(ans==0)
ans=1;
ans=1LL*ans*fac[sum[i]-1]%mod*fast_pow(fac[num[i]-1],mod-2)%mod*fast_pow(fac[sum[i]-num[i]],mod-2)%mod;
ans%=mod;
}
cout<<ans;
}