Advanced2000

Different Arrays

Codeforces
View on Codeforces
Time: 2 secondsMemory: 512 megabytes

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.

Input

The first line contains one integer n (3 ≤ n ≤ 300).The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 300).

Output

Print one integer — the number of reachable arrays. Since the answer can be very large, print its remainder modulo 998244353.

Examples

Input
4 1 1 1 1
Output
3
Input
5 1 2 3 5 0
Output
7
brute forcedpimplementation

Discussion

(0)
Sign in to join the discussion.
Loading editor...
0 online