2 4 4 1 2 3 5 1 2 3 4 5
3 0 Hint: For the first testcase:Moving in the order of $book3,book2,book1$ ,$(4,1,2,3)\rightarrow (3,4,1,2)\rightarrow(2,3,4,1)\rightarrow(1,2,3,4)$,and this is the best way to reorder the books. For the second testcase:It's already ordered so there is no operation needed.