AtCoder Regular Contest 104
E
Random LIS
AtCoder
⌀ 2824
原题
← DF →
翻译中…

Problem Statement

翻译中…

Given is an integer sequence of length $N$: $A_1, A_2, \cdots, A_N$.

翻译中…

An integer sequence $X$, which is also of length $N$, will be chosen randomly by independently choosing $X_i$ from a uniform distribution on the integers $1, 2, \ldots, A_i$ for each $i (1 \leq i \leq N)$.

翻译中…

Compute the expected value of the length of the longest increasing subsequence of this sequence $X$, modulo $1000000007$.

翻译中…

More formally, under the constraints of the problem, we can prove that the expected value can be represented as a rational number, that is, an irreducible fraction $\frac{P}{Q}$, and there uniquely exists an integer $R$ such that $R \times Q \equiv P \pmod {1000000007}$ and $0 \leq R < 1000000007$, so print this integer $R$.

翻译中…

Note

翻译中…

A subsequence of a sequence $X$ is a sequence obtained by extracting some of the elements of $X$ and arrange them without changing the order. The longest increasing subsequence of a sequence $X$ is the sequence of the greatest length among the strictly increasing subsequences of $X$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 6$
  • $1 \leq A_i \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

Print the expected value modulo $1000000007$.

翻译中…

样例

Input #1
3
1 2 3
Output #1
2
$X$ becomes one of the following, with probability $1/6$ for each: - $X = (1,1,1)$, for which the length of the longest increasing subsequence is $1$; - $X = (1,1,2)$, for which the length of the longest increasing subsequence is $2$; - $X = (1,1,3)$, for which the length of the longest increasing subsequence is $2$; - $X = (1,2,1)$, for which the length of the longest increasing subsequence is $2$; - $X = (1,2,2)$, for which the length of the longest increasing subsequence is $2$; - $X = (1,2,3)$, for which the length of the longest increasing subsequence is $3$. Thus, the expected value of the length of the longest increasing subsequence is $(1 + 2 + 2 + 2 + 2 + 3) / 6 \equiv 2 \pmod {1000000007}$.
Input #2
3
2 1 2
Output #2
500000005
$X$ becomes one of the following, with probability $1/4$ for each: - $X = (1,1,1)$, for which the length of the longest increasing subsequence is $1$; - $X = (1,1,2)$, for which the length of the longest increasing subsequence is $2$; - $X = (2,1,1)$, for which the length of the longest increasing subsequence is $1$; - $X = (2,1,2)$, for which the length of the longest increasing subsequence is $2$. Thus, the expected value of the length of the longest increasing subsequence is $(1 + 2 + 1 + 2) / 4 = 3 / 2$. Since $2 \times 500000005 \equiv 3 \pmod {1000000007}$, we should print $500000005$.
Input #3
6
8 6 5 10 9 14
Output #3
959563502
题目信息
题号
arc104_e
时间限制
2 s
内存限制
1024 MB

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