there bookshelf fit n book the ith position bookshelf a_i 1 book position a_i 0 it guarantee book bookshelfIn choose contiguous segment l r consist book ie l r condition a_i 1 hold shift right 1 book index 1 l le le r this r1 le n book position r1 Shift leave 1 book index i1 l le le r this l1 ge 1 book position l1 your task find minimum number move require collect book shelf contiguous consecutive segment ie segment gapsfor example 0 0 1 0 1 gap book a_4 0 a_3 1 a_5 1 1 1 0 gap book 0 00 gap booksyou answer t independent test case