#K92232. Minimizing Delays to Prevent Flower Withering

    ID: 38152 Type: Default 1000ms 256MiB

Minimizing Delays to Prevent Flower Withering

Minimizing Delays to Prevent Flower Withering

You are given a sequence of N flowers represented by integers. When two consecutive flowers are of the same type, the later one might wither unless a delay operation is performed. Your task is to determine the minimum number of delay operations required so that no flower withers.

In other words, whenever two consecutive flowers are identical, you must insert a delay between them. Mathematically, if a group of k consecutive identical flowers appears, the number of delays needed for that group is given by \( k - 1 \). For example, if \( k = 4 \), then the required delays are \( 3 \).

inputFormat

The first line contains an integer N (the number of flowers). The second line contains N space-separated integers representing the types of the flowers.

outputFormat

Output a single integer, which is the minimum number of delay operations required.

## sample
6
3 1 3 1 3 1
0