题目描述
Problem Description
There is a game as follows:
A certain character is arranged in a vertical column of $N$ characters. The colors of these characters are either red, blue, or yellow, and in the initial state, no same-colored characters are consecutively arranged for more than 3 times. The player can choose a character at a certain position and change its color to another. This operation causes the characters of the same color consecutively arranged for more than 3 times to disappear. The disappearance of characters may cause new same-colored characters to consecutively arrange for more than 3 times, and these characters will also disappear. This chain continues until there are no more same-colored characters consecutively arranged for more than 3 times. The goal of this game is to minimize the number of characters that remain without disappearing.
For example, in the leftmost state of the figure below, if the color of the 6th character from the top is changed from yellow to blue, then 5 blue characters will consecutively arrange, causing them to disappear, and finally, 3 characters will remain without disappearing.

Given the initial arrangement of the colors of $N$ characters, create a program to find the minimum number $M$ of characters that remain without disappearing when only one character's color is changed.
Input Format
The first line contains only the number of characters $N$ ($1 \leq N \leq 10,000$). The following $N$ lines contain one integer each, where the $(i+1)$-th line ($1 \leq i \leq N$) represents the color of the $i$-th character from the top in the initial state (1 for red, 2 for blue, and 3 for yellow).
Output Format
Output the minimum number $M$ of characters that remain without disappearing.
Sample Input and Output
Sample Input #1
12
3
2
1
1
2
3
2
2
2
1
1
3
Sample Output #1
3
Sample Input #2
12
3
2
1
1
2
3
2
1
3
2
1
3
Sample Output #2
12
Notes/Hints
Sample Explanation 1
- - - - - -
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分