March to the Median
One move changes any element by ±1. Print the minimum total moves to make ALL elements equal.
Input: the first line has N; the second line has N integers.
Output: the minimum number of ±1 moves.
Constraints:
- 1 ≤ N ≤ 105
- |ai| ≤ 109
Sample Tests
Input 1
3 1 2 9
Output 1
8
Input 2
2 5 5
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.