#K2496. Minimum Moves to Equalize Array Elements
Minimum Moves to Equalize Array Elements
Minimum Moves to Equalize Array Elements
Given an array of integers, the task is to compute the minimum number of moves required to make all array elements equal by only incrementing the elements. In each move, you can choose an element and increment it by 1. The final value to which all elements are raised is the maximum value originally present in the array.
The required number of moves is given by the formula: $$moves = \sum_{i=1}^{n}(M - a_i)$$, where \(M\) is the maximum element in the array, \(a_i\) is the i-th element, and \(n\) is the number of elements.
inputFormat
The input is provided via standard input (stdin). The first line contains a single integer \(N\) representing the number of elements in the array (\(1 \leq N \leq 10^5\)). The second line contains \(N\) space-separated integers representing the array elements.
outputFormat
Print a single integer to standard output (stdout) representing the minimum number of moves needed to make all the array elements equal.
## sample3
1 2 3
3