## Task B-1.5.

A sequence of $n$ white and $n$ black tiles is arranged such that black and white tiles alternate, starting with a white tile. The goal is to rearrange the tiles so that all black tiles are together at the beginning of the sequence, and all white tiles are at the end. The only allowed move is to swap adjacent tiles. What is the minimum number of such swaps needed to achieve the goal?