显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 10;
const int lcy = 998244353;
int n, top;
int num[maxn];
int inv[maxn * 5], f[maxn * 5];
inline int quick_pow(LL base, int times) {
LL res = 1;
while (times) {
if (times & 1) res = (res * base) % lcy;
times >>= 1;
base = (base * base) % lcy;
}
return (int)res;
}
#define is_num(x) (x <= '9' and x >= '0')
inline int get_num() {
char tmp = getchar();
int res = 0;
while (not is_num(tmp)) tmp = getchar();
while ( is_num(tmp)) {
res = (res << 3) + (res << 1) + tmp - '0';
tmp = getchar();
}
return res;
}
inline void init() {
f[0] = f[1] = 1;
for (int i = 2; i <= top; i++) f[i] = 1ll * f[i - 1] * i % lcy;
inv[top] = quick_pow(f[top], lcy - 2);
for (int i = top - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % lcy;
}
inline void read() {
n = get_num();
for (int i = 1; i <= n; i++) {
num[i] = get_num();
top += num[i];
}
}
inline void solve() {
int sum = 0;
int ans = 1;
for (int i = 1; i <= n; i++) {
sum += num[i];
ans = 1ll * ans * f[sum - 1] % lcy * inv[num[i] - 1] % lcy * inv[sum - num[i]] % lcy;
}
printf("%d\n", ans);
}
int main() {
freopen("asm_formation.in", "r", stdin);
freopen("asm_formation.out", "w", stdout);
read();
init();
solve();
return 0;
}