We go through the array from left to right or reverse.

[1]count the all number of dress we need to operate with the other side up to now as A (that means the dress we have to give out or we lack).

[2]in every step, the Math.abs(A) maybe final answer.

[3]for every machine, if it have more dress than avg, it must will take (his dress number)-(avg) times operate to make it be in avg. So it also maybe the final answer.