题目描述
Problem Description
You are given a sequence \(a_1, a_2, \ldots, a_n\). You can perform several operations on this sequence.
Suppose the length of the sequence before an operation is \(m\). During an operation, you can choose an integer \(i\) such that \(1 \le i \le m - 1\) and \(a_i \ne a_{i + 1}\). You then delete \(a_{i + 1}\) and set the value of \(a_i\) to any integer.
Determine the maximum number of operations you can perform.
Input Format
The first line contains a positive integer \(n\), representing the initial length of the sequence.
The second line contains \(n\) positive integers \(a_1, a_2, \ldots, a_n\).
Output Format
A single line containing a non-negative integer, representing the maximum number of operations that can be performed.
Sample Input and Output
Sample Input #1
2
1 2
Sample Output #1
1
Sample Input #2
3
1 1 1
Sample Output #2
0
Sample Input #3
4
1 1 45 14
Sample Output #3
3
Notes
Sample Explanation #1
You can choose \(i = 1\), delete \(a_2\), and set the value of \(a_1\) to 3. Now \(a = [3]\), and no further operations can be performed. Thus, the answer is 1.
Sample Explanation #2
No operations can be performed, so the answer is 0.
Data Range
This problem uses batched testing and has subtask dependencies enabled.
| Subtask Number | Score | \(n \le\) | Special Conditions | Subtask Dependencies |
|---|---|---|---|---|
| 1 | 34 | 2 | None | None |
| 2 | 19 | \(10^5\) | \(a_1 = a_2 = \cdots = a_n\) | None |
| 3 | 47 | \(10^5\) | None | 1, 2 |
For all data, \(1 \le n \le 10^5\) and \(1 \le a_i \le 10^9\).
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分