#K40042. Lucky Array Transformation

    ID: 26554 Type: Default 1000ms 256MiB

Lucky Array Transformation

Lucky Array Transformation

You are given t test cases. For each test case, you are provided with an integer n and an array of n integers. An array is considered lucky if it contains at least one occurrence of two consecutive identical numbers. In other words, an array a[1..n] is lucky if there exists an index i (where $1 \le i < n$) such that $a_i = a_{i+1}$.

Your task is to determine the minimum number of operations required to make the given array lucky. In one operation, you can change any element of the array to any integer of your choice. If the array is already lucky, no operations are required (i.e. the answer is 0). Otherwise, you can make it lucky by performing exactly 1 operation.

Note: The operation count will always be either 0 or 1.

inputFormat

The first line contains an integer t denoting the number of test cases. Each test case is described as follows:

  • The first line of each test case contains an integer n — the number of elements in the array.
  • The second line contains n space-separated integers representing the elements of the array.

All input is read from standard input (stdin).

outputFormat

For each test case, print a single integer — the minimum number of operations required to make the array lucky. Each answer should be printed on a new line on standard output (stdout).

## sample
1
6
1 2 3 4 5 6
1

</p>