{"raw_statement":[{"iden":"background","content":"本题是 1-1 的较难版本，较易版本为 [1-1 A](https://www.luogu.com.cn/problem/P8847)。"},{"iden":"statement","content":"给出一个序列 $a$，$\\forall i\\in [1,n],a_i\\in \\{1,-1\\}$。\n\n询问有多少个将 $a$ 重排后的序列使得该序列的最大子段和最小化。\n\n称两个序列不同，当且仅当这两个序列有任意一个位置上的数不同。"},{"iden":"input","content":"第一行一个整数 $n$。\n\n第二行 $n$ 个整数表示 $a$。"},{"iden":"output","content":"一个整数表示答案。答案对 $998244353$ 取模。"},{"iden":"note","content":"最大子段和的定义：序列中一段区间的和的最大值。即 $\\max_{1\\le l\\le r\\le n} \\sum_{i=l}^r a_i$。\n\n### 数据规模\n本题采用捆绑测试。\n\n| $\\text{Subtask}$ | $n\\le$ | $\\text{Score}$ |\n| :----------: | :----------: | :----------: |\n| $1$ | $10$ | $20$ |\n| $2$ | $100$ | $20$ |\n| $3$ | $500$ | $20$ |\n| $4$ | $10^4$ | $40$ |\n\n对于 $100\\%$ 的数据，$1\\le n\\le 10^4$，$a_i\\in \\{1,-1\\}$。"}],"translated_statement":null,"sample_group":[["4\n1 -1 1 -1","3"],["5\n1 1 1 -1 1","3"],["10\n1 1 1 1 1 1 1 -1 -1 -1","40"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}