Description
You are given a positive integer $N$, a prime number $P$, and a sequence of positive integers $A = (A_1, A_2, \dots, A_N)$ of length $N$, where each element is less than $P$. Let $S = \{1, 2, \dots, N\}$.
Find the number of sequences $T$ of sets with length at least $1$ that satisfy all of the following conditions, and output the result modulo $P$.
- Every element of $T$ is a non-empty subset of $S$.
- For each $i = 1, 2, \dots, N$, the following holds:
- Among the elements of $T$, exactly $A_i$ of them contain $i$.
Input
The input is given in the following format:
N P A_1 A_2 ... A_N
- $1 \le N \le 2 \times 10^5$
- $113 \le P \le 500009$
- $P$ is a prime number
- $1 \le A_i < P$ ($1 \le i \le N$)
- All input values are integers
Output
Print the answer.
Examples
2 113
1 2
5
4 8191
7 6 3 8
4477
Note
For the first example, the possible sequences $T$ are $(\{1, 2\}, \{2\})$, $(\{2\}, \{1, 2\})$, $(\{1\}, \{2\}, \{2\})$, $(\{2\}, \{1\}, \{2\})$, $(\{2\}, \{2\}, \{1\})$, for a total of $5$.
For the second example, do not forget to find the number of valid sequences $T$ modulo $P$.