Petya has N \cdot k (1 \le N \le 15000) matches, distributed among boxes arranged in a row. Petya wants each box to contain the same number of matches. He can move a match to an adjacent box. What is the minimum number of such operations needed to achieve the desired configuration?
The first line contains the integer .
The second line contains integers, each not exceeding 10^9, representing the number of matches in each box (the first number is the number of matches in the first box, the second in the second box, and so on).
Output the minimum number of operations needed to achieve the desired configuration.
Example 1