You are given an array \$a\$ of integers. With a move you can increase or decrease an element of the array by 1. Your task is to equalize the array, that is make all the elements of the array equal by performing some moves. But that's not enough! You also want to make as few moves as possible.
- A non-empty array \$a\$ of integers
- Optionally, the length of \$a\$.
- The minimum number of moves needed to equalize the array \$a\$.
- Standard rules for valid submissions, I/O, loopholes apply.
- This is code-golf, so shortest solution (in bytes) wins. As usual, don't let ridiculously short solutions in golfy languages discourage you from posting a longer answer in your language of choice.
- This is not a rule, but your answer will be better received if it includes a link to test the solution and an explanation of how it works.
Input --> Output  --> 0 [-1, 0, 1] --> 2 [4, 7] --> 3 [6, 2, 3, 8] --> 9 [5, 8, 12, 3, 2, 8, 4, 5] --> 19 [1,10,100] --> 99