Bit Operation

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

You are given an integer array AA of length NN, consisting of 00's and 11's. Let aa be initially the array AA. You are going to perform the following operation N1N-1 times.

  • Let nn be the current length of aa. Choose an integer ii (1in11 \leq i \leq n-1) and delete the ii-th and the (i+1)(i+1)-th elements of aa. Then, by letting xx and yy be the deleted elements, insert either x\mathbin{\\&}y or xyx\mathbin{|}y to the position of the deleted elements. Here x\mathbin{\\&}y and xyx\mathbin{|}y denote the bit-AND and bit-OR operations, respectively.

There are 2N1×(N1)!2^{N-1} \times (N-1)! ways to perform the operations. Count the number of ways that result in a single value of 11, modulo 998244353998244353.

입력

The first line contains an integer NN (1N1061 \leq N \leq 10^6).

The second line contains integers A_1,A_2,,A_NA\_1,A\_2,\ldots,A\_N (0A_i10 \leq A\_i \leq 1).

출력

Print the answer.