#agc026d. [agc026_d]Histogram Coloring
[agc026_d]Histogram Coloring
Problem Statement
Let us consider a grid of squares with rows and columns. Let be the square at the -th column from the left and -th row from the bottom.
Snuke has cut out some part of the grid so that, for each , the bottom-most squares are remaining in the -th column from the left. Now, he will paint the remaining squares in red and blue. Find the number of the ways to paint the squares so that the following condition is satisfied:
- Every remaining square is painted either red or blue.
- For all and , there are exactly two squares painted red and two squares painted blue among the following four squares: and .
Since the number of ways can be extremely large, print the count modulo .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the number of the ways to paint the squares, modulo .
Sample Input 1
9
2 3 5 4 1 2 4 2 1
Sample Output 1
12800
One of the ways to paint the squares is shown below:
#```