There are $$$n$$$ balls arranged in a row. Each ball is painted in one of ten possible colors. In one operation, you can swap two adjacent 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 $$$10$$$ — the colors of the balls.
Print one integer — the minimum number of swaps.
42 1 2 1
1
| Name |
|---|


