Score : $1000$ points
There are $N$ buildings under construction arranged in a row, numbered $1, 2, \ldots, N$ from left to right.
Given is an integer sequence $X$ of length $N$. The height of Building $i$, $H_i$, can be one of the integers between $1$ and $X_i$ (inclusive).
For each $i$ such that $1 \leq i \leq N$, let us define $P_i$ as follows:
Considering all possible combinations of the buildings' heights, find the number of integer sequences that $P$ can be, modulo $1000000007$.
Input is given from Standard Input in the following format:
$N$ $X_1$ $X_2$ $\cdots$ $X_N$
Print the number of integer sequences that $P$ can be when all possible combinations of the buildings' heights are considered, modulo $1000000007$.
3 3 2 1
4
We have six candidates for $H$, as follows:
Thus, there are four integer sequences that $P$ can be: $(-1, -1, -1), (-1, -1, 2), (-1, 1, 1)$, and $(-1, 1, 2)$.
3 1 1 2
1
We have two candidates for $H$, as follows:
Thus, there is one integer sequence that $P$ can be.
5 2 2 2 2 2
16
13 3 1 4 1 5 9 2 6 5 3 5 8 9
31155