#K74227. Minimum Moves to Equalize Elements
Minimum Moves to Equalize Elements
Minimum Moves to Equalize Elements
You are given a list of integers. In one move, you are allowed to increment every element except one by 1. Your task is to determine the minimum number of moves required to make all the elements of the list equal.
This problem can be understood as follows: in each move, you effectively decrease the difference between the maximum and the minimum values by bringing the larger numbers closer to the smallest number. The optimal strategy is to focus on reducing every element to the minimum value. Mathematically, if the list is represented as \(a_1, a_2, \dots, a_n\), then the number of moves required is given by:
\(moves = \sum_{i=1}^{n} (a_i - \min(a))\)
For example, given the list [1, 2, 3], the minimum number of moves required is 3.
inputFormat
The first line of input contains an integer \(n\), representing the number of elements in the list.
The second line contains \(n\) space-separated integers which represent the elements of the list.
outputFormat
Output a single integer indicating the minimum number of moves required to equalize all the elements in the list.
## sample3
1 2 3
3