fork download
  1. i = input()
  2. while ( i != -1):
  3. packs = []
  4. for j in range(i):
  5. packs.insert(input)
  6. sum = reduce(lambda a, b: a+b, packs)
  7. if sum % i != 0:
  8. print "-1"
  9. else:
  10. desired = sum / i
  11. print reduce(lambda a, b: a+b, map(lambda x: desired - x, filter(lambda x: x < desired,packs)))
  12.  
  13.  
  14.  
Runtime error #stdin #stdout 0.03s 6356KB
stdin
5
1
1
1
1
6
2
3
4
-1
stdout
Standard output is empty