P10202 [Hubei NOI Qualifier Mock 2024] Chenyu Valley / jade
Background
If there were no gods under heaven, this would be the kingdom of humans.
Description
You will preside over a ritual. The ritual uses $N$ jade stones arranged in a line, numbered from left to right as $1,2,\cdots,N$. The color of jade stone $i$ is $a_i$.
In each round of the ritual, you need to choose a consecutive segment of jade stones with the same color $a_l \sim a_r(1\le l \le r\le N\le 50)$, and sink them into the water. The immortal power value $K$ of this ritual will become $10000\cdot K+100\cdot l+r$, where the initial value of $K$ is $0$.
After a segment of jade stones is sunk into the water, the jade stones on the right will shift left. **At the same time, the numbering will also change**, and they will be renumbered from left to right as $1,2,\cdots$. For example, there are $7$ jade stones with colors $1,1,2,2,2,3,2$. At the beginning, the jade stone with color $3$ is numbered $6$. After jade stones $3\sim 5$ are sunk into the water, its number will become $3$.
When all jade stones have been sunk into the water, the ritual is completed, and the value of $K$ at this time is the immortal power value of this ritual. How many different immortal power values are possible after the ritual is completed?
Since the answer may be very large, you only need to output the value modulo $10^9+7$.
Input Format
The input has two lines.
The first line contains a positive integer $N$, representing the number of jade stones.
The second line contains $N$ positive integers $a_1,a_2,\cdots,a_N$, where $a_i$ represents the color of the $i$-th jade stone.
Output Format
Output one line with one integer, representing the number of different immortal power values modulo $10^9+7$.
Explanation/Hint
### Sample Explanation 3
Here are two possible immortal power values and the ways to obtain them:
1. $(1,\underline{2},1,2,1) \xrightarrow{K=202} (1,1,\underline{2},1) \xrightarrow{K=2\ 020\ 303} (\underline{1},\underline{1},1) \xrightarrow{K=20\ 203\ 030\ 102} (\underline{1}) \xrightarrow{K=202\ 030\ 301\ 020\ 101} ()$, obtaining the immortal power value $K$ as $202\ 030\ 301\ 020\ 101$.
2. $(1,2,\underline{1},2,1) \xrightarrow{K=303} (1,\underline{2},\underline{2},1) \xrightarrow{K=3\ 030\ 203} (\underline{1},\underline{1}) \xrightarrow{K=30\ 302\ 030\ 102} ()$, obtaining the immortal power value $K$ as $30\ 302\ 030\ 102$.
### Subtasks
For all testdata, it is guaranteed that $1 \le N \le 50$ and $1 \le a_i \le N$.
| Test Point ID | $N\le$ | Special Property |
| :--: | :--: | :--: |
| $1\sim 2$ | $18$ | None |
| $3$ | $50$ | A |
| $4$ | $50$ | B |
| $5\sim 8$ | $50$ | C,D |
| $9\sim 12$ | $50$ | C |
| $13\sim 16$ | $50$ | D |
| $17\sim 25$ | $50$ | None |
Special Property A: It is guaranteed that $a_i=i$.
Special Property B: It is guaranteed that $a_i=1$.
Special Property C: It is guaranteed that there do not exist $p_1