CANDY  Candy I
Jennifer is a teacher in the first year of a primary school. She has gone for a trip with her class today. She has taken a packet of candies for each child. Unfortunatelly, the sizes of the packets are not the same.
Jennifer is afraid that each child will want to have the biggest packet of candies and this will lead to quarrels or even fights among children. She wants to avoid this. Therefore, she has decided to open all the packets, count the candies in each packet and move some candies from bigger packets to smaller ones so that each packet will contain the same number of candies. The question is how many candies she has to move.
Input specification
The input file consists of several blocks of data. Each block starts with the number of candy packets N(1<= N <=10000) followed by N integers (each less than 1000) in separate lines, giving the number of candies in each packet. After the last block of data there is the number 1.
Output specification
The output file should contain one line with the smallest number of moves for each block of data. One move consists of taking one candy from a packet and putting it into another one. If it is not possible to have the same number of candies in each packet, output the number 1.
Example
Input file: 5 1 1 1 1 6 2 3 4 1 Output file: 4 1
hide comments
thiyagumessi:
20191208 15:22:16
Hint: Don't complicate it, it's easy 

sandipan2224:
20191203 15:30:58
AC yeah!! 

kenneth_esmond:
20191021 10:30:35
ez 

rohit_mahale:
20191004 16:32:21
AC in 2nd go!!( little implementation error gave a bloody failure. 

mkk_2305:
20191002 22:14:01
Last edit: 20191002 22:14:14 

pankajnegi_113:
20190926 20:05:48
AC in 2 go xD 

jshreyansh:
20190821 01:35:47
Why does the output have a '4' shouldn't it be just '1'? Last edit: 20190821 01:36:00 

kaizoku876:
20190725 21:24:56
AC in one go!! lads 

rikilg:
20190718 13:24:45
AC in one go! 

klaus_9:
20190707 07:42:50
AC in 10^9+7 gos 
Added by:  Fudan University Problem Setters 
Date:  20071201 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: C99 ERL JSRHINO 
Resource:  IPSC 1999 