Zenyk and problems
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk wants to spend Valentine’s Day with Marichka in the mountains. Skis, slopes, ice rink, hot tub, algorithms — romance! They are leaving tomorrow. Bags are packed, so today Zenyk still has time to participate in an algorithmic programming competition. He quickly came up with solutions to all the problems, and now he only needs to implement all the necessary algorithms.
There are \(n\) problems in the competition. To solve the \(i\)-th problem, Zenyk needs to implement algorithm \(a_i\).
Since implementing algorithms from scratch takes a lot of time, Zenyk can save time by reusing the algorithm implementation from the last problem he solved. If the next problem uses a different algorithm than the previous one, Zenyk will simply delete the implementation of the previous algorithm and start implementing the new one from scratch.
Zenyk is an experienced competitive programmer, so he always solves all problems in order starting from the first one.
How many times will he need to implement an algorithm from scratch?
Input
The first line contains an integer \(n\) — the number of problems.
The second line contains \(n\) integers \(a_i\) — the algorithm number required to solve the \(i\)-th problem.
Output
Print an integer — how many times Zenyk will need to implement an algorithm from scratch.
Constraints
\(1 \le n \le 10^5\),
\(1 \le a_i \le n\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7 1 2 2 2 3 1 1 | 4 |
Notes
In the example, Zenyk will implement algorithms from scratch for the first, second, fifth, and sixth problems.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|