{"problem":{"name":"Reversi","description":{"content":"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 ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc031_b"},"statements":[{"statement_type":"Markdown","content":"There are $N$ stones arranged in a row. The $i$\\-th stone from the left is painted in the color $C_i$.\nSnuke will perform the following operation zero or more times:\n\n*   Choose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\nFind the number of possible final sequences of colors of the stones, modulo $10^9+7$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2\\times 10^5$\n*   $1 \\leq C_i \\leq 2\\times 10^5(1\\leq i\\leq N)$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$C_1$\n$:$\n$C_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc031_b","tags":[],"sample_group":[["5\n1\n2\n1\n2\n2","3\n\nWe can make three sequences of colors of stones, as follows:\n\n*   $(1,2,1,2,2)$, by doing nothing.\n*   $(1,1,1,2,2)$, by choosing the first and third stones to perform the operation.\n*   $(1,2,2,2,2)$, by choosing the second and fourth stones to perform the operation."],["6\n4\n2\n5\n4\n2\n4","5"],["7\n1\n3\n1\n2\n3\n3\n2","5"]],"created_at":"2026-03-03 11:01:14"}}