#C13901. Minimum Moves to Equal Array Elements

    ID: 43491 Type: Default 1000ms 256MiB

Minimum Moves to Equal Array Elements

Minimum Moves to Equal Array Elements

You are given a list of non-negative integers. In one move, you may increment or decrement any element by 1. Your task is to determine the minimum number of moves required to make all elements of the array equal.

It can be shown that converting all elements to the median minimizes the total number of moves. If the input list is empty, then no moves are required. If any element is negative or not an integer, the program should raise an error.

Note: All formulas in this problem are represented in LaTeX format. For example, if the median is \(m\), then the total number of moves is given by \(\sum_{i=1}^{n} |a_i - m|\).

inputFormat

The input is provided via standard input (stdin) as a single line containing a sequence of space-separated integers. If the line is empty, the array is considered empty.

Constraints: All numbers must be non-negative integers.

outputFormat

Output a single integer on standard output (stdout) representing the minimum number of moves required to make all array elements equal.

## sample
0