atcoder#ARC140D. [ARC140D] One to One
[ARC140D] One to One
Score : points
Problem Statement
For an integer sequence of length whose elements are all between and (inclusive), consider the question below, and let be the answer.
$$G$$$$N$$$$G$$$$N$$$$i$$$$i$$$$X_i$$$$G$$You are given an integer sequence $A=(A_1,A_2,\dots,A_N)$ of length $N$, where each $A_i$ is an integer between $1$ and $N$ (inclusive) or $-1$. $$
Consider an integer sequence of length whose elements are all between and such that . Find the sum of over all such , modulo .
Constraints
- is between and (inclusive) or .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Prin the answer.
3
-1 1 3
5
There are three sequences satisfying the requirement, as follows.
- , for which the answer to the question is .
- , for which the answer to the question is .
- , for which the answer to the question is .
Thus, the answer is .
1
1
1
8
-1 3 -1 -1 8 -1 -1 -1
433760