#K66007. Minimum Operations to Form a Beautiful Sequence

    ID: 32324 Type: Default 1000ms 256MiB

Minimum Operations to Form a Beautiful Sequence

Minimum Operations to Form a Beautiful Sequence

You are given an integer n and an array of n positive integers. A sequence is considered beautiful if no two adjacent elements are equal. In one operation, you may remove one element from any pair of adjacent equal elements. Your task is to determine the minimum number of operations required to transform the given array into a beautiful sequence.

Formally, if the array is denoted as \(a_1, a_2, \dots, a_n\), you must count the number of indices \(i\) (where \(2 \le i \le n\)) such that \(a_i = a_{i-1}\). This count is the minimum number of operations required.

Input and Output Format: The input is given via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line of input contains a single integer n representing the length of the array. The second line contains n space-separated positive integers representing the array \(a_1, a_2, \dots, a_n\).

outputFormat

Print a single integer: the minimum number of operations required to make the array a beautiful sequence.

## sample
1
5
0