There are $$$n$$$ balls arranged in a row. Each ball is painted in one of three possible colors. In one operation, you may swap any two balls.
Determine the minimum number of such swaps required so that, in the end, all balls of the same color stand consecutively. In other words, there must not be two balls of the same color with balls of other colors between them.
The first line of the input contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$).
The second line contains $$$n$$$ integers from $$$1$$$ to $$$3$$$ — the colors of the balls.
Print one integer — the minimum number of swaps.
52 1 2 2 1
1