#arc114b. [arc114_b]Special Subsets
[arc114_b]Special Subsets
Problem Statement
Let be a set composed of all integers from through .
is a function from to . You are given the values as .
Find the number, modulo , of non-empty subsets of satisfying both of the following conditions:
-
For every , .
-
For every , if .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of non-empty subsets of satisfying both of the conditions, modulo .
Sample Input 1
2
2 1
Sample Output 1
1
We have . Since , the second condition is always satisfied, but the first condition requires to contain and simultaneously.
Sample Input 2
2
1 1
Sample Output 2
1
We have . The first condition requires to contain , and the second condition forbids to contain .
Sample Input 3
3
1 2 3
Sample Output 3
7
We have . Both of the conditions are always satisfied, so all non-empty subsets of count.