using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
WillReturn.Add("2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
//10
}
else if (InputPattern == "Input2") {
WillReturn.Add("358");
WillReturn.Add("1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0");
//64
}
else if (InputPattern == "Input3") {
WillReturn.Add("1000");
WillReturn.Add("1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000");
//270274035
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
const long Hou = 998244353;
static void Main()
{
List<string> InputList = GetInputList();
long StrLen = long.Parse(InputList[0]);
long UB = StrLen;
long[] CArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray();
var InsChooseMod = new ChooseMod(StrLen, Hou);
// 場合の数[使用した文字数]なインラインDP表
long[] DPArr = new long[UB + 1];
DPArr[0] = 1;
long Answer = 0;
foreach (long EachC in CArr) {
if (EachC == 0) continue;
for (long I = UB; 0 <= I; I--) {
if (DPArr[I] == 0) continue;
long RestStr = StrLen - I;
// 使う文字数でループ
for (long J = 1; J <= EachC; J++) {
if (RestStr < J) break;
long PatternCnt = InsChooseMod.DeriveChoose(RestStr, J);
long AddVal = DPArr[I] * PatternCnt;
AddVal %= Hou;
DPArr[I + J] += AddVal;
DPArr[I + J] %= Hou;
long DuplicateCnt = InsChooseMod.DeriveChoose(StrLen, I + J);
long Gyakugen = DeriveGyakugen(DuplicateCnt);
Answer += AddVal * Gyakugen;
Answer %= Hou;
}
}
}
Console.WriteLine(Answer);
}
// 引数の逆元を求める
static Dictionary<long, long> mMemoGyakugen = new Dictionary<long, long>();
static long DeriveGyakugen(long pLong)
{
if (mMemoGyakugen.ContainsKey(pLong)) {
return mMemoGyakugen[pLong];
}
return mMemoGyakugen[pLong] = DeriveBekijyou(pLong, Hou - 2, Hou);
}
// 繰り返し2乗法で、(NのP乗) Mod Mを求める
static long DeriveBekijyou(long pN, long pP, long pM)
{
long CurrJyousuu = pN % pM;
long CurrShisuu = 1;
long WillReturn = 1;
while (true) {
// 対象ビットが立っている場合
if ((pP & CurrShisuu) > 0) {
WillReturn = (WillReturn * CurrJyousuu) % pM;
}
CurrShisuu *= 2;
if (CurrShisuu > pP) return WillReturn;
CurrJyousuu = (CurrJyousuu * CurrJyousuu) % pM;
}
}
}
#region ChooseMod
// 二項係数クラス
internal class ChooseMod
{
private long mHou;
private long[] mFacArr;
private long[] mFacInvArr;
private long[] mInvArr;
// コンストラクタ
internal ChooseMod(long pCnt, long pHou)
{
mHou = pHou;
mFacArr = new long[pCnt + 1];
mFacInvArr = new long[pCnt + 1];
mInvArr = new long[pCnt + 1];
mFacArr[0] = mFacArr[1] = 1;
mFacInvArr[0] = mFacInvArr[1] = 1;
mInvArr[1] = 1;
for (int I = 2; I <= pCnt; I++) {
mFacArr[I] = mFacArr[I - 1] * I % mHou;
mInvArr[I] = mHou - mInvArr[mHou % I] * (mHou / I) % mHou;
mFacInvArr[I] = mFacInvArr[I - 1] * mInvArr[I] % mHou;
}
}
// nCrを返す
internal long DeriveChoose(long pN, long pR)
{
if (pN < pR) return 0;
if (pN < 0 || pR < 0) return 0;
return mFacArr[pN] * (mFacInvArr[pR] * mFacInvArr[pN - pR] % mHou) % mHou;
}
}
#endregion