AtCoder Regular Contest 206 (Div. 2)
A
Range Replace
AtCoder
⌀ 554
原题
←B →
翻译中…

Problem Statement

翻译中…

You are given a sequence $A=(A_1,\ldots,A_N)$ of length $N$. You perform the following operation exactly once.

翻译中…
  • Choose a pair of integers $(L,R)$ such that $1\leq L \leq R \leq N$. Replace each of $A_L,A_{L+1},\ldots,A_R$ with $A_L$.
翻译中…

How many different sequences are possible as $A$ after the operation?

翻译中…

Constraints

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

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 \ldots A_N

翻译中…

Output

翻译中…

Output the answer.

翻译中…

样例

Input #1
4
1 1 2 3
Output #1
4
The possible sequences after the operation are the following four sequences: - $(1,1,1,1)$ - $(1,1,1,3)$ - $(1,1,2,2)$ - $(1,1,2,3)$ For example, $(1,1,1,3)$ can be obtained by performing the operation with $L=2,R=3$.
Input #2
10
2 5 6 5 2 1 7 9 7 2
Output #2
41
题目信息
题号
arc206_a
时间限制
2 s
内存限制
1024 MB

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