AtCoder Grand Contest 026
D
Histogram Coloring
AtCoder
⌀ 2746
原题
← CE →
翻译中…

Problem Statement

翻译中…

Let us consider a grid of squares with $10^9$ rows and $N$ columns. Let $(i, j)$ be the square at the $i$-th column $(1 \leq i \leq N)$ from the left and $j$-th row $(1 \leq j \leq 10^9)$ from the bottom.

翻译中…

Snuke has cut out some part of the grid so that, for each $i = 1, 2, ..., N$, the bottom-most $h_i$ squares are remaining in the $i$-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 $1 \leq i \leq N-1$ and $1 \leq j \leq min(h_i, h_{i+1})-1$, there are exactly two squares painted red and two squares painted blue among the following four squares: $(i, j), (i, j+1), (i+1, j)$ and $(i+1, j+1)$.
翻译中…

Since the number of ways can be extremely large, print the count modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 100$
  • $1 \leq h_i \leq 10^9$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
h_1 h_2 ... h_N

翻译中…

Output

翻译中…

Print the number of the ways to paint the squares, modulo $10^9+7$.

翻译中…

样例

Input #1
9
2 3 5 4 1 2 4 2 1
Output #1
12800
One of the ways to paint the squares is shown below:
Input #2
2
2 2
Output #2
6
There are six ways to paint the squares, as follows:
Input #3
5
2 1 2 1 2
Output #3
256
Every way to paint the squares satisfies the condition.
Input #4
9
27 18 28 18 28 45 90 45 23
Output #4
844733013
Remember to print the number of ways modulo $10^9 + 7$.
题目信息
题号
agc026_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。