AtCoder Regular Contest 104
F
Visibility Sequence
AtCoder
⌀ 3213
原题
← E→
翻译中…

Problem Statement

翻译中…

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:

翻译中…
  • If there is an integer $j (1 \leq j < i)$ such that $H_j > H_i$, $P_i$ is the maximum such $j$. Otherwise, $P_i$ is $-1$.
翻译中…

Considering all possible combinations of the buildings' heights, find the number of integer sequences that $P$ can be, modulo $1000000007$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 100$
  • $1 \leq X_i \leq 10^5$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
X_1 X_2 \cdots X_N

翻译中…

Output

翻译中…

Print the number of integer sequences that $P$ can be when all possible combinations of the buildings' heights are considered, modulo $1000000007$.

翻译中…

样例

Input #1
3
3 2 1
Output #1
4
We have six candidates for $H$, as follows: - $H = (1, 1, 1)$, for which $P$ is $(-1, -1, -1)$; - $H = (1, 2, 1)$, for which $P$ is $(-1, -1, 2)$; - $H = (2, 1, 1)$, for which $P$ is $(-1, 1, 1)$; - $H = (2, 2, 1)$, for which $P$ is $(-1, -1, 2)$; - $H = (3, 1, 1)$, for which $P$ is $(-1, 1, 1)$; - $H = (3, 2, 1)$, for which $P$ is $(-1, 1, 2)$. Thus, there are four integer sequences that $P$ can be: $(-1, -1, -1), (-1, -1, 2), (-1, 1, 1)$, and $(-1, 1, 2)$.
Input #2
3
1 1 2
Output #2
1
We have two candidates for $H$, as follows: - $H = (1, 1, 1)$, for which $P$ is $(-1, -1, -1)$; - $H = (1, 1, 2)$, for which $P$ is $(-1, -1, -1)$. Thus, there is one integer sequence that $P$ can be.
Input #3
5
2 2 2 2 2
Output #3
16
Input #4
13
3 1 4 1 5 9 2 6 5 3 5 8 9
Output #4
31155
题目信息
题号
arc104_f
时间限制
2 s
内存限制
1024 MB

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