Colored Balls#3916

Colored Balls

1 second
64 megabytes
Easy

In a computer game, players arrange balls of various colors in a line. When a sequence of three or more consecutive balls of the same color appears, that sequence is removed. The remaining balls then shift to fill the gap, potentially creating new sequences that can also be removed.

Write a program to calculate how many balls will be removed in total, given an initial arrangement. Initially, there will be at most one sequence of three or more identical balls.

Input

The input consists of the number of balls in the line (up to ) and the colors of these balls, represented by integers from to , where each integer corresponds to a specific color.

Output

Output the total number of balls that will be removed.

Examples

Example 1

Loading
Loading