You are given an array $$$a$$$ consisting of $$$n$$$ integers.
You have to perform the sequence of $$$n-2$$$ operations on this array:
So, during the $$$i$$$-th operation, you add the value of $$$a_{i+1}$$$ to one of its neighbors, and subtract it from the other neighbor.
For example, if you have the array $$$[1, 2, 3, 4, 5]$$$, one of the possible sequences of operations is:
So, the resulting array is $$$[3, 1, -4, 5, 10]$$$.
An array is reachable if it can be obtained by performing the aforementioned sequence of operations on $$$a$$$. You have to calculate the number of reachable arrays, and print it modulo $$$998244353$$$.
The first line contains one integer $$$n$$$ ($$$3 \le n \le 300$$$).
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i \le 300$$$).
Print one integer — the number of reachable arrays. Since the answer can be very large, print its remainder modulo $$$998244353$$$.
4 1 1 1 1
3
5 1 2 3 5 0
7
Name |
---|