Score : $700$ points
There are $N$ isu - chairs in Japanese - arranged from left to right. The $i$-th chair from the left has the ID number $a_i$. Here, it is guaranteed that $a_i$ are distinct.
Snuke has decided to mark some of the chairs and throw away the rest. Initially, no chair is marked. We call a choice of marked chairs good when the IDs of the marked chairs are monotonically increasing from left to right.
Snuke has decided to do the following procedure to mark chairs:
It can be proved that the expected value of the number of chairs that remain at the end of the procedure is a rational number. Let this value be $P/Q$, an irreducible fraction. Additionally, let $M=10^{9}+7$. Then, we can prove that there uniquely exists an integer $R$ between $0$ and $M-1$ (inclusive) such that $P \equiv Q \times R \pmod{M}$, and that value equals $P \times Q^{-1} \pmod{M}$, where $Q^{-1}$ is the modular multiplicative inverse of $Q$. Find $R$.
Input is given from Standard Input in the following format:
$N$ $a_1$ $a_2$ $\cdots$ $a_N$
Print $R$.
3 3 1 2
666666673
30 26 16 28 30 23 11 29 18 22 15 20 13 27 9 21 7 5 25 4 19 8 3 1 24 10 14 17 12 2 6
297703424