The necklace consists of beads of 4 different colors. The owner wants to keep beads of only 3 colors. Find the minimum number of beads that need to be removed from the necklace if the string can be cut only once, and the beads must be removed consecutively. Removed beads cannot be returned, and the remaining string is tied together.
The program reads from the keyboard the number of beads (4 \leq N \leq 5000), followed by integers in the same line separated by spaces, each representing the color of a bead ( for yellow, for blue, for red, for green).
The program outputs a single integer — the minimum number of beads to be removed.
Example 1