E. Colored Balls - 1
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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.

Output

Print one integer — the minimum number of swaps.

Example
Input
5
2 1 2 2 1
Output
1