#abc230f. F - Predilection

F - Predilection

Score : 500500 points

## 问题陈述

已知长度为 $N$ 的序列 $A$。你可以执行任意次数的操作:当序列长度至少为 $2$ 时,选择两个相邻的数值,删除它们,并将它们的和插入到原来的位置。经过零次或多次操作后,可以得到多少种不同的序列?请在求得结果后对 $998244353$ 取模。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given is a sequence AA of length NN. You can do this operation any number of times: when the length of the sequence is at least 22, choose two adjacent values, delete them, and insert their sum where they were. How many sequences can result from zero or more operations? Find the count modulo 998244353998244353.

Constraints

  • 1N2×1051 \leq N \leq 2\times 10^5
  • Ai109|A_i| \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \cdots ANA_N

Output

Print the answer.

Sample Input 1

3
1 -1 1

Sample Output 1

4

The following four sequences can result from zero or more operations.

  • 1,1,1{1,-1,1}
  • 1,0{1,0}
  • 0,1{0,1}
  • 1{1}

Sample Input 2

10
377914575 -275478149 0 -444175904 719654053 -254224494 -123690081 377914575 -254224494 -21253655

Sample Output 2

321

update @ 2024/3/10 10:03:49