The input
consists of several data sets. Each set begins with a line containing the number
n of stacks Bob has built. The next line contains n numbers, the heights hi of
the n stacks. You may assume 1 <= n <= 50 and 1 <= hi <=
100.
The total number of bricks will be divisible by the number of
stacks. Thus, it is always possible to rearrange the bricks such that all stacks
have the same height.
The input is terminated by a set starting with n = 0. This set should not be processed.
6
5 2 4 1 7 5
0
Set #1
The minimum number of moves is 5.