Younghee, a teacher at an algorithm kindergarten, handed out candy to the children at snack time. But the greedy children ignored the order and grabbed candy at random, so some ended up with a lot while others got almost none and started to cry.
So Younghee proposed a game. All the children sit in a circle. Each round consists of the following two steps, in order:
After repeating this a number of times, every child ends up holding the same number of candies and the game ends.
Treating one ‘give half to the right’ step together with the following ‘teacher tops up’ step as a single round, determine how many rounds are needed until every child holds the same number of candies.
Note: if some children start with an odd number of candies, the teacher first tops them up to an even number, and this initial top-up is not counted as a round. Assume the teacher has more than enough candy.
Input is given through standard input. The first line contains the number of test cases T. Each test case consists of two lines. The first line contains the number of children N (1≤N≤10), and the second line contains the number of candies each child starts with, C1,C2,…,CN (1≤Ci≤30), separated by spaces. The seating is arranged so that C2 sits to the right of C1, C3 to the right of C2, and so on, with C1 sitting to the right of CN.
For each test case, print on its own line the number of rounds required until every child holds the same number of candies.