AtCoder Grand Contest 031
B
Reversi
AtCoder
⌀ 1315
原题
← AC →
翻译中…

Problem Statement

翻译中…

There are $N$ stones arranged in a row. The $i$-th stone from the left is painted in the color $C_i$.

翻译中…

Snuke will perform the following operation zero or more times:

翻译中…
  • Choose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.
翻译中…

Find the number of possible final sequences of colors of the stones, modulo $10^9+7$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2\times 10^5$
  • $1 \leq C_i \leq 2\times 10^5(1\leq i\leq N)$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
C_1
:
C_N

翻译中…

Output

翻译中…

Print the number of possible final sequences of colors of the stones, modulo $10^9+7$.

翻译中…

样例

Input #1
5
1
2
1
2
2
Output #1
3
We can make three sequences of colors of stones, as follows: - $(1,2,1,2,2)$, by doing nothing. - $(1,1,1,2,2)$, by choosing the first and third stones to perform the operation. - $(1,2,2,2,2)$, by choosing the second and fourth stones to perform the operation.
Input #2
6
4
2
5
4
2
4
Output #2
5
Input #3
7
1
3
1
2
3
3
2
Output #3
5
题目信息
题号
agc031_b
时间限制
2 s
内存限制
1024 MB

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