Several cards with numbers printed on them are lined up on the table.
We’d like to change their order so that first some are in non-decreasing order of the numbers on them, and the rest are in non-increasing order. For example, (1, 2, 3, 2, 1), (1, 1, 3, 4, 5, 9, 2), and (5, 3, 1) are acceptable orders, but (8, 7, 9) and (5, 3, 5, 3) are not.
To put it formally, with n the number of cards and bi the number printed on the card at the i-th position
)
after reordering, there should exist

such that
%20%5Ctext%20%7B%20and%20%7D%5Cleft(b_%7Bi%7D%20%5Cgeq%20b_%7Bi%2B1%7D%20%5Cvee%20i%20%5Cin%5C%7Bk%2C%20%5Cldots%2C%20n-1%5C%7D%5Cright))
hold.
For reordering, the only operation allowed at a time is to swap the positions of an adjacent card pair. We want to know the minimum number of swaps required to complete the reorder.